php - Encoding issue with MySQLi -
I have a MySQL table that I have set to use encoding
utf8_swedish_ci . Two example values are 2 kung and 1. NN - Note the Swedish character I have to find these internationalization strings from within a PHP script. My PHP file is encoded in UTF-8 . My code, with error coding stripped for clarity, looks like this: $ db = new mysqli ($ host, $ user, $ password, $ user); $ Db- & gt; Set_charset ('UTF-8'); $ Stm = $ db- & gt; Prepare ('Select' id 'myTable' Where is' Buck 'like?'); The echo is searching for "$ value" ...; $ stm- & gt; dam_pram ('s', $ value); $ stm- & gt; executed ($); $ stm- & gt; bind_result ($ result ); $ Stm- & gt; pass (); resonant "received result". '; Now if I set the $ value to the first example value, then I get a matching row with another example value I do not get a line to work in PHPMyAdmin The query is examined that I consider this error lie with the international character and so I messed up somewhere else encodings. So what did I do wrong and how do I fix it?
Edit : line $ db-> set_charset ('UTF-8'); fails because I used the wrong charset it should be utf8 . I have very little error handling, let me have $ db-> Error should be examined after set_charset .
$ db-> Set_churset ('UTF-8'); Keep in mind that MySQL is special, that name internally uses the UTF-8 character set utf8 (without dashes ), Not regular UTF-8 . In the case of doubt, show the character set; ;)
Comments
Post a Comment