0

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
QuinnBaetz
  • 559
  • 9
  • 23

1 Answers1

1

You probably need to set your connection to use utf-8 aswell. You can set it in your configuration, or set it using this function.

More information: here.

Wesley van Opdorp
  • 14,888
  • 4
  • 41
  • 59
  • 2
    [You shouldn’t use `SET NAMES`.](http://stackoverflow.com/questions/5288953/is-mysql-real-escape-string-broken/5289141#5289141) – Gumbo Jun 22 '11 at 07:08