Database data in the browser display garbled (with the browser, the same data source, the same utf8, different servers)

Source: Internet
Author: User
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).

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.