Question

I have table Users (with UTF8 character set and utf8_general_ci collation) which has lastName column (same character set and collation as table). When I insert my name (Štěrba) into this table and column directly from Navicat for MySQL, it's correctly displayed in Navicat, but badly in browser (output document is UTF8 and after mysql_connect() I also use SET CHARACTER SET utf8):

Correctly in Navicat, wrongly in browser

But when I do this insert from PHP with this query:

INSERT INTO users (firstName, lastName) values ('Pavel', 'Štěrba');

it's displayed correctly in browser, but in Navicat it's saved like this:

Wrongly in Navicat, correctly in browser

Obviously, I can't edit it directly from navicat because I will break it... Have you got any idea, why this happen? Did I miss encoding somewhere? Or it's issue with Navicat? Thanks for tips!

Was it helpful?

Solution

Chances are high YOU are doing it wrong, and not the tools everyone uses.

Do not fiddle with the encoding setting via queries! Use mysql_set_charset().

You have to repair all entries in your database that got there via PHP.

Note that "SET CHARACTER SET" is wrong, although it sounds like the right thing. If you cannot use the above PHP function, all you should do is use "SET NAMES utf8" only!

OTHER TIPS

use SET NAMES utf8 also after SET CHARACTER SET utf8

i hope this help

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top