Mysql – How to read Chinese character from MySQL to PHP page by resin server

charsetMySQLPHPresinutf-8

My characters are in Chinese Simplified that stored in MySQL database by all tables and character set to UTF-8.

I am reading them to my PHP page that runs under resin server on Windows XP Professional.

My Resin server version is 4.0.15; PHP version is 5.3.2; and MySQL is 5.5.

Any idea how to retrieve the Chinese character data to my PHP page and displaying them in correct Chinese words? I get the Question Mark ("?") on those Chinese characters.

If I am typing Chinese character on PHP page, it can display correct Chinese words on web page. So, I assume is the connection between MySQL and PHP have problem.

But previously when I was running under Apache, there is no character problem.
May I know why?

Best Answer

Try issuing a mysql command as soon as you open a db connection from php

"set names utf8;"

My guess is though, if it worked on apache, then its likely the character set of the html that is wrong. Add some character set headers in your web server config, todeclare that the document is utf. Perhaps its defaulting to latin as some do?

Hard to say what else might be causing it, without more info. But character set issues can often be quite frustrating to troubleshoot

Related Topic