My database table is UTF-8 however when querying it through PHP the characters come out different.
When viewing the data in the database it appears like this:
汕头å›åŽå¤§é…’店
but in PHP it comes out as
汕头åÂÂââ
I have noticed that when I encode the data with base64_encode before inserting into mysql then decode it when it comes out then it shows correctly in the PHP and browser and shows as it does in the database:
汕头å›åŽå¤§é…’店
But there is data where I can't encode it first so I can't always do this so I'm wondering why mysql_query makes it come out differently. I've tried many things
Doing before the query:
mysql_query ("set character_set_results='utf8'");
and
mysql_query("SET NAMES UTF8");
Doing this before the query:
mb_internal_encoding('UTF-8'); mb_http_output('UTF-8'); mb_http_input('UTF-8');
This is my html page header
"meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /"
using utf8_decode on the field in question but seems to make it worse
But it makes no different to the output I can see both the correct (the base64_decode ) and incorrect characters in the same page
thanks!
header("Content-Type: application/html; charset=utf-8");
– John