The page displays the Incorrect string and database content garbled, incorrectstring

Source: Internet
Author: User

The page displays the Incorrect string and database content garbled, incorrectstring

I encountered the error Incorrect string on the page when I was making a network for fighting people (www.helpqy.com). I am using mysql and the data table contains a lot of Chinese content, at last, we found that we need to select the default collection when installing mysql. There are two main options: latin1, which is mainly used for pure foreign text websites, and UTF8, it is mainly used in Chinese or Chinese-English websites. I re-installed mysql and chose default collation as UTF8 to solve the problem.

Another problem encountered during the debugging process is that the Chinese content read from the database on the page is garbled. Finally, it is found that in the database, it is precisely a table in the database, the collation option is also available, and each field also has the collation option. developers can solve the problem by making adjustments based on actual conditions.

 


The Chinese content is submitted on the page. The page is garbled with the "Chinese" content of the database.

Localhost: 3306/Database Name? CharacterEncoding = UTF-8 (same as page encoding)
If it still doesn't work, write a filter and filter it.
If you have any questions, ask me directly.
References: tiangao cloud light (◆ simplified Simply)

Garbled characters appear in the Chinese part of the page when the database content is displayed on the PHP page.

Generally, garbled characters are caused by inconsistent codes. To solve PHP Chinese garbled characters, follow these steps:

1. the encoding of the page declaration is consistent with the internal encoding of the database.

For example, if charset = gb2312 is set on your webpage, however, if your database uses UTF-8, it may be displayed if iconv conversion is not performed.

2. the encoding of the page file is consistent with that of the page declaration.

For example, your webpage file is test. php, Which is saved in UTF-8B format, and if charset = gb2312 is set in your webpage, the display may be abnormal.

From your problem description, we can see that "the Chinese characters of the exported parts of PHP are normal". Based on this, we can determine that the page file encoding is consistent with the page declaration encoding. The cause is:

The encoding of the page declaration is inconsistent with the internal encoding of the database.

You can check your database encoding format and Webpage-defined encoding.

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.