Detect php what is wrong in my code

define("EW_ENCODING", "utf-8", TRUE); 
$encode = EW_ENCODING ;
mysql_set_charset(EW_ENCODING,$con);
$charset = mysql_client_encoding($con);

echo "The current character set is: $charset\n";

Why does this code not print utf-8? When I run this code, it actually prints

The current character set is: latin1

How can I get the desired result?

+3
source share
2 answers

MySQL uses non-standard character set names. Try utf8without a dash.

+7
source

Try to call

mysql_query("SET NAMES utf8;");

also.

+3
source

All Articles