Database Data is garbled in the browser (the same browser, the same data source, the same utf8, different servers)

Source: Internet
Author: User
For the same mysql Data Source and the same browser, there is no garbled code for accessing the online test, and there is garbled code for accessing localhost. I think this is a problem with the server environment? Note: Chinese characters are displayed normally in mysql. Supplement: local and test server php. in ini, all default_charset values are commented out... for the same mysql Data Source and the same browser, there is no garbled code for accessing the online test, and there is garbled code for accessing localhost. I think this is a problem with the server environment?

Note: Chinese characters are displayed normally in mysql.
Supplement: local and test server php. inidefault_charsetAll are commented out.
Supplement: my bad, I used to think it should not be the problem of setting character encoding in mysql (based on the same Code). When I try to specify character encoding, the problem can be solved. Generally speaking, there are three Encoding Problems: php, mysql, and browser settings.

Reply content:

For the same mysql Data Source and the same browser, there is no garbled code for accessing the online test, and there is garbled code for accessing localhost. I think this is a problem with the server environment?

Note: Chinese characters are displayed normally in mysql.
Supplement: local and test server php. inidefault_charsetAll are commented out.
Supplement: my bad, I used to think it should not be the problem of setting character encoding in mysql (based on the same Code). When I try to specify character encoding, the problem can be solved. Generally speaking, there are three Encoding Problems: php, mysql, and browser settings.

According to your statement, since the database is the same, the browser is the same, and the code is certainly the same, the problem basically lies in php,
1. Check whether the default encoding of your php configuration is UTF-8. You 'd better check it with phpinfo ().

default_charset = "utf-8";

2. Check whether the encoding rules are set in the connection abstraction layer of your database where php interacts with MySQL. If mysqli is used, at least set it like this.

$mysqli->set_charset("utf8")

1. Does the head of the HTML document specify the same encoding as that specified by the backend handler?
2. Check whether the encoding of the table or field in the database is consistent with that of the back-end program (if it is inconsistent, for example, forced conversion of GBK UTF-8 may cause garbled code ).

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.