-2

I'm building a php search page for a photo gallery to pull data with Chinese characters from MySQL.

I've done the following:

1. setting webpage to utf-8 encoding meta http-equiv="content-type" content="text/html";charset="utf-8"
2. ensure that the collation for mysql db and data itself is utf8_general_ci
3. set chrome encoding to utf-8. 

But when I put in a positive search string to pull data with Chinese characters, they always come up as ???

I've checked my php array raw output and it is also ??? which leads me to believe there is something wrong at my database end. But I need to add is my gallery page (where the search box is embedded) displays the Chinese characters correctly from the same database.

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
  • Have you also set `$mysqli->set_charset('utf8');`? – Michel Jun 03 '14 at 08:25
  • Hi Jason, thank you so much - that fixed the problem. I've created different db connect files for my gallery and search page. And I have forgotten to add that line - I use mysql_query("SET NAMES 'UTF8'"); - in the db connect for search page. Not a programmer by trade by any means in case you wonder why would I make 2 db connect files. Could you help me close this by 'answering' for this post? – user3253555 Jun 03 '14 at 08:43
  • You shouldn't use mysql but mysqli. Mysql is depricated. And don't use `SET NAMES UTF8`. See the [manual example 2](http://www.php.net/manual/en/mysqlinfo.concepts.charset.php) – Michel Jun 03 '14 at 10:21
  • noted with thanks, Michel – user3253555 Jun 03 '14 at 11:32

1 Answers1

0

Have you also set $mysqli->set_charset('utf8'); ?

Michel
  • 4,076
  • 4
  • 34
  • 52