Search code examples
phpmysqlcharacternon-latin

Getting mysql by php turns non-latin characters into question mark "?"


When I echo values with non-latin characters from MySQL they turn into question marks. And I mean question marks "?" not "�". I got these things:

header('Content-Type: text/html; charset=ISO-8859-2'); //php

<meta name="charset" content="ISO-8859-2" />//html

And they're not working!

Requesting help.

EDIT: More informations: in PHPMyAdmin I changed collation to utf8_polish_ci.


Solution

  • You might want to try issuing this SQL statement right after you connect:

    SET character_set_results = latin2 
    

    It looks like your text is getting translated, by MySQL, from Unicode to latin-1 (iso-8859-1); the question marks you're seeing are replacement characters. MySQL translates text from its internal representation to the character set of the connection when it sends result sets.

    You can read more about this here. http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html