In MySQL I have a string, which is displayed properly in phpmyadmin, with the collation set to utf8_general_ci .
In the PHP file, I have set the header using plain HTML:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
The php files are hosted on Ubuntu, Apache 2.2, and the files are saved in UTF-8 without BOM (using Notepad++)
I have set the connection to use utf8:
@mysql_query("set names 'utf8'", $this->link);
$r = @mysql_query($query, $this->link);
it returns the string ( varchar 255 ) and using PHP echo , it is displayed to the browser.
However, I am still getting ????? instead of the actual words.
I can’t seem to be able to searched for what I might have missed, your help is much appreciated.
===== Edit =====
Database, table and column can have three different collations, I have set them all to utf8_general_ci , and calling mysql_set_charset(‘utf8’) immediately after the connection is made, have solved my problem.
I hope this will act as a useful checklist for future people bumping into the same problem. I for one may very well return in a few months to check if I have missed anything 🙂
Thanks all for the great input.
Be sure your table is in
utf8_general_ci.Database and tables can have a different charset
(can happen when you change it by yourself).
And be careful with some functions, like htmlentities,
which have a default charset parameter set to ISO-8859-1 for PHP <5.4.0
(set to UTF-8 for PHP >5.4.0)
http://php.net/manual/en/function.htmlentities.php