Latin characters in phpMyAdmin with UTF-8 mapping

My site uses:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> 

And this meta:

 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 

I created my database and tables in phpMyAdmin, making sure everything is set to utf8_unicode_ci (table, fields, database), even connection mapping.

When I insert Latin characters (accents, etc.) into the database using the standard form written in PHP, it works fine, I can display the saved data on my website without any problems. But if I go to phpMyAdmin, all Latin characters will be corrupted, something like à ± à ± à ±.

If I try to fix this data in phpMyAdmin, then my site will display the data incorrectly, with strange characters.

What am I doing wrong in this world? I tried to work this for several hours without success.

Thanks everyone!

+4
source share
7 answers

As @Artefacto reports, this could be a local issue for phpMyAdmin.

If phpMyAdmin is fine (i.e. configured to UTF-8) and the data is still displayed weirdly, then see if your database connection is using UTF-8?

 mysql_query("SET NAMES utf8") 

(or whatever you use as a database library) may help if it isn't.

+9
source

If phpMyAdmin shows ñññ instead of ñññ , it is because it interprets the UTF-8 stream stream as ISO-8859-1. So your database contents are probably correct, phpMyAdmin just shows them incorrectly.

I am not familiar with the application, but you can make the browser read the page as UTF-8 (usually View> Encoding> UTF-8).

+1
source

for Scuzzu Question there are several ways:

http://www.mysqlperformanceblog.com/2007/12/18/fixing-column-encoding-mess-in-mysql/

I would have eight more links with different tasks, but this site does not allow me to save them ...

"as a mechanism for preventing spam, new users can post a maximum of one hyperlink"

+1
source

mysql_query ("SET NAMES utf8") solved my problem.

Problem: characters are displayed correctly in phpMyAdmin, incorrectly in HTML / PHP. Characters: â, î etc.

The headers are in order (utf8), phpmyadmin displays the content in the correct form, but the website continues to show strange question marks (inside the black diamond symbol).

HTML code:

<!DOCTYPE html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

Solution: I added in php (before any other requests):

mysql_query("SET NAMES utf8");

Other causes may lead to this behavior; this is only one part of the solution. You may need to check the content type, web server configuration (httpd.conf), html lang / dir, charset, etc. However, the question mark in black diamond seems to be more specific to this problem / solution, in other cases 2-3 strange characters are displayed, not the one you want.

+1
source

After executing mysql_query("SET names 'utf8';"); You also need to switch to mySQL and define the sort as UTF-8, too! This should solve your problem. Good luck

0
source

1- Edit file:

my.ini (MsWindos)
my.cnf (GNU / linux)

2 Find the [mysqld] entry and add:

  character-set-server = utf8 skip-character-set-client-handshake 

The whole view should look like this:

 [mysqld] port=3306 character-set-server = utf8 skip-character-set-client-handshake 

3- Restart the MySQL service!

0
source

If phpMyAdmin is fine (i.e. configured to UTF-8) and the data is still displayed weirdly, then see if your database connection is using UTF-8?

Just set mysql_query("SET NAMES utf8"); after mysql_connect :

 $con = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD) or die(mysql_error()); mysql_query("SET NAMES utf8"); 
0
source

Source: https://habr.com/ru/post/1311905/


All Articles