Monty
Monty

Reputation: 304

phpMyAdmin won't display or insert Unicode characters properly into database

I'm using phpMyAdmin version 4.4.4 with MySQL 5.6 (charset is set to UTF-8 Unicode). The table in question has the collation set to utf8-general-ci and all fields are also set to utf8-general-ci collation as well. My php.ini file has default_charset = "UTF-8".

Despite all the UTF-8 settings for all three applications, unicode characters appear garbled when viewing a table within phpMyAdmin. So, instead of seeing ...

Søren

... in phpMyAdmin I see ...

Søren

Even though it displays garbled in phpMyAdmin, it displays correctly on the website. The only problem is with phpMyAdmin.

If I attempt to Insert a new record using phpMyAdmin and enter Søren in a text field, it displays like this within phpMyAdmin...

Søren

Which looks correct there, but, on the web page, it displays like this...

S�ren

The ø character is replaced with a question mark inside a black diamond instead of displaying the proper unicode character on the website.

What the heck is going on? How do I make phpMyAdmin display and insert the unicode characters properly into the table without mangling them? Thanks!

Upvotes: 1

Views: 2066

Answers (1)

bobince
bobince

Reputation: 536349

My php.ini file has default_charset = "UTF-8".

That only affects the charset used for some PHP built-in functions like htmlentities.

MySQL uses its own charset to decode stuff you send it. This can be set using $mysqli->set_charset('utf8') for mysqli, or mysql_set_charset('utf8') for the deprecated mysql module, or using charset=utf8 in the connection string in PDO.

Upvotes: 1

Related Questions