0

Terms in foreign languages (such as French, Chinese, etc.) have been entered into my MySQL table via PHP programs. But when I go to search using this term, it does not find the record. The reason appears to be that the term entered is stored in the MySQL table differently.

For example, in the MysQL table, the entry is Anémie. But when this was entered via PHP (and when it is displayed via PHP), it shows as Anémie. While the data appears to be there is a way that hasn't lost meaning, it makes it impossible to do a search by entering Anémie. I would like the table to contain Anémie so a search will succeed.

I have checked the table and it is encoded as UTF8. However, not all of the character set variables are UTF8.

"character_set_client" ["Value"]=> string(6) "latin1" } "character_set_connection" ["Value"]=> string(6) "latin1" } "character_set_database" ["Value"]=> string(4) "utf8" } "character_set_results" ["Value"]=> string(6) "latin1" } "character_set_server" ["Value"]=> string(6) "latin1" } "character_set_system" ["Value"]=> string(4) "utf8" }

I have also tried to follow the MySQL manual's advice on changing from one character set to another by using the alter table, change to blob and then using the alter table change back to varchar with the character set of utf8. But this has had no effect.

Two questions. First, how can I convert the data in the MySQL table so a search will find it? Second, how do I ensure that future entries come into the table as entered?

1 Answers1

0

One thing to consider is that you must set the connection character set to UTF-8. This is almost always forgotten.

Exactly how you do this depends on the library you're using. For PDO, you would simply append ;charset=utf8 to your connection string.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
  • I'm using the old fashioned PHP approach on this application. Still maintaining unconverted applications. My connection string is "$connection=mysql_connect('abc.com','xxx','yyy') – user3624182 May 10 '14 at 20:55