0

I have some php files that have utf-8 characters in. The files are saved with the utf-8 encoding. I am also specifically setting the page charset to UTF-8. Browser shows them correctly if directly output in the source code. But when getting field data from my MySQL tables (using mysqli connection), question marks are displayed instead of content. Does anyone know what it could be? I am assuming it has to do with the database interaction?

HTTP Response header:

HTTP/1.1 200 OK
Date: Mon, 18 Feb 2013 23:05:13 GMT
Server: Apache/2.2.22 (Unix) DAV/2 PHP/5.4.9
X-Powered-By: PHP/5.4.9
Content-Length: 2161
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=utf-8
mavili
  • 3,385
  • 4
  • 30
  • 46
  • Is the data stored in your database in utf 8? – Benjamin Gruenbaum Feb 18 '13 at 23:14
  • 2
    Perhaps you forgot `$mysqli->set_charset('utf8');`? – Ja͢ck Feb 18 '13 at 23:15
  • did you output the text from DB in console at runtime and check what is being retrieved from DB – user1428716 Feb 18 '13 at 23:15
  • sounds like perhaps mysql isn't storing in UTF-8, or your driver isn't retrieving the data as UTF-8. this may help you out: http://cameronyule.com/2008/07/configuring-mysql-to-use-utf-8/ – Joshua Burns Feb 18 '13 at 23:31
  • thanks for all of you guys. @BenjaminGruenbaum yes the data is stored in utf8, that was not the problem. I tried your link @JoshuaBurns but for some reason I got error when trying to start mysql server with those settings in the `my.cnf` file. `mysqli->set_charset()` did the job :) – mavili Feb 19 '13 at 00:15
  • FWIW: If anyone else like me was having trouble with utf-8 values in a mysql db being properly DISPLAYED as HTML, this web page fixed me right up: http://www.webmastertools.bz/how-to-display-utf-8-characters-web-page/ It's not enough just to get the chars correct in the db--you still gotta display those rascals on the frontend! – cbmtrx Nov 15 '15 at 01:08

1 Answers1

0

reinstall mysql server and enable utf-8 supporting , this usually happens on localhost

  • 1
    reinstall?? why not just change settings? reinstalling is like turning your computer off and on again for not deleting a character :D – mavili Feb 19 '13 at 00:16