Problems with Chinese characters

the following problems:

I have a mysql database with Chinese characters (stored as utf8_general_ci). In phpmyadmin, Chinese characters are printed correctly.

Now I am getting database values ​​using mysqli:

$stmt = $mysqli->prepare("SELECT *** FROM projects p WHERE PID = ***");
$stmt->execute();
$stmt->store_result();

$stmt>bind_result(***);
$stmt->fetch();

      

Chinese characters are now displayed as "????".

The page encoding is set to:

<meta charset="utf-8">

      

What am I doing wrong?

Thanks in advance.

+3


source to share


2 answers


You have to tell MYSQL that it will be done in UTF8 for this to work.



The easier it is, after you connect to the database, execute this query: SET NAMES 'utf8'

which, once and before disconnecting, will tell mysql that you are about to talk in UTF8.

+1


source


The PHP file must have its encoding set as UTF8, not ASCII.



0


source







All Articles