I moved data from MySQL 4 (they were originally set to latin2 encoding
) to MySQL 5 and set encoding to utf-8
. It
On my server, adding these to my php file had no effect:
ini_set('default_charset','utf-8');
mysql_set_charset('utf8');
header('Content-type: text/html; charset=utf-8');
But everything worked perfectly once I added this to the top of my php file:
$mysqli->query("SET NAMES 'utf8'");
Note: I am using encoding utf8_general_ci
in my database, but utf8_unicode_ci
works the same for me.
Hope that helps.