Forum Moderators: coopster

Message Too Old, No Replies

Insert and view of UTF-8 in phpMyAdmin

         

DeezerD

5:00 pm on Aug 17, 2007 (gmt 0)

10+ Year Member



Hi there

here is my problem:
I can't insert correctly characters encoded in UTF-8 in my database (I use phpMyAdmin to deal with the data in there)
The thing is when I check the content of my tables, I get weird characters for foreign characters. For example, when I send a japanese character with a form from my own website, I get 症治疗取 in phpMyAdmin

The page that contains my form has a UTF-8 charset and my table collation is utf8_bin.
The other thing is that when I send my request directly in phpmyadmin, all the characters are well inserted and everything is right.

So I guess I must be missing some function to deal with the data I send with my form so that it will be well UTF 8 encoded but I don't see what I should use

Thanks for your help

whoisgregg

6:05 pm on Aug 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It could be that MySQL is re-encoding what PHP has already encoded. Tell MySQL that you are sending it UTF-8 data using SET NAMES [dev.mysql.com]:

 SET NAMES 'utf8';
INSERT/UPDATE/etc.;

If that fixes the problem, then follow the instructions on the linked page if you'd like to change the default so you don't need to run SET NAMES each time.

DeezerD

8:19 pm on Aug 17, 2007 (gmt 0)

10+ Year Member



gregg thank you so much
adding mysql_query("SET NAMES 'UTF8'") solved my problem :)

whoisgregg

9:34 pm on Aug 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Happy to help. :)

And, before I completely forget my manners, Welcome to WebmasterWorld [webmasterworld.com]!