Bad characters when printing text from utf8_unicode_ci Mysql table

I am inserting / updating text into utf8_unicode_ci encoded table with mysql_query("SET NAMES 'utf8'");

In mysql table, it displays as "ş,", ü ". But when I print it using PHP,

it looks like "??" On the page.

I tried to add

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> 

      

but doesn't work.

How can I display Unicode characters correctly on a page?

thank

0


source to share


2 answers


You must use:

mysql_set_charset('utf8');

      

instead



mysql_query("SET NAMES 'utf8'")

      

and I suggest to set headers in PHP too

header('Content-Type: text/html; charset=UTF-8');

      

+10


source


UTF-8 settings for PHP:



ini_set("mbstring.language", "Neutral");
ini_set("mbstring.internal_encoding", "UTF-8");
ini_set("mbstring.encoding_translation", "On");
ini_set("mbstring.http_input", "auto");
ini_set("mbstring.http_output", "UTF-8");
ini_set("mbstring.detect_order", "auto");
ini_set("mbstring.substitute_character", "none");
ini_set("default_charset", "UTF-8");
ini_set("mbstring.func_overload", 7);

setlocale(LC_TIME, "en_US.UTF-8");

      

0


source







All Articles