Faizan Shah Faizan Shah - 4 years ago 95
SQL Question

MYSQL name field not taking name in other languages

I have this field

display_name varchar(30) latin1_swedish_ci


it takes English names as usual, but this database deals in different languages, and also users from all around enter there names, some of which are in different languages. french lets say, and a name stored in french is displayed like this
???????

what could be the reason? i believe it has something to do with this
latin1_swedish_ci
how can i make this field generic to take and display any name in any language correctly?

Answer Source

You need to call:

mysql_set_charset("utf8");

Also refer: 10.1.10 Unicode Support

Or the other way is to use utf-8 in MYSQL by adding this to your my.cnf:

collation_server = utf8_unicode_ci
character_set_server = utf8

and when you are executing your query the first use these two queries:

SET NAMES 'utf8';
CHARSET 'utf8';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download