The same MySQL data source, the same browser, access line test without garbled, localhost access is garbled, I think this is not a server environment problem?
Added: Chinese display in MySQL is normal.
Add: Both local and test server php.ini are default_charset
commented out.
Add: My bad, I am accustomed to think that should not be the problem of MySQL set character encoding (based on the same code), when I try to specify the character encoding, the problem is resolved. Common sense, the coding problem is nothing more than three places, Php,mysql, browser settings, all unified problems are generally not.
Reply content:
The same MySQL data source, the same browser, access line test without garbled, localhost access is garbled, I think this is not a server environment problem?
Added: Chinese display in MySQL is normal.
Add: Both local and test server php.ini are default_charset
commented out.
Add: My bad, I am accustomed to think that should not be the problem of MySQL set character encoding (based on the same code), when I try to specify the character encoding, the problem is resolved. Common sense, the coding problem is nothing more than three places, Php,mysql, browser settings, all unified problems are generally not.
According to you, since the database is the same, the browser is the same, the code is certainly the same, then basically the problem is in PHP,
1. Check if the default encoding for your PHP configuration is utf-8, it's best to take phpinfo () to see
default_charset = "utf-8";
2. Check your database connection abstraction layer, where PHP interacts with MySQL, whether the encoding rules are set, if you're using mysqli, at least set it up.
$mysqli->set_charset("utf8")
1. The head of the HTML document specifies a consistent encoding specified by the backend handler.
2, check the database in the table or the field used by the encoding, whether the code consistent with the backend program (inconsistent, such as UTF-8 forcibly GBK may cause garbled).