php screws up utf-8 charachters from mysql database using mysqli

请求翻译

I have some chinese characters (e.g. 中文(简体)) stored in a mysql database with content type utf8_bin.

I am pulling from the database with this code:

if($stmt = $mysqli->prepare("SELECT c_color FROM colors")){
   $stmt->execute();    
   $stmt->bind_result($ccolor);
   $stmt->store_result();
   if($stmt->fetch()){
       //$ccolor is filled with question marks
   }

What am I doing wrong? I have

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

and the page is displaying Chinese characters on it. Seems like a problem with php.

1个回答