Chinese characters in phpmyadmin are garbled in English.

Source: Internet
Author: User
The Chinese characters in phpmyadmin are garbled characters, but this problem is not found after we connect to the mysql database using php. The problem is that the content of our database is correct and only the phpmyadmin encoding is incorrect, below is a simple introduction... the Chinese characters in phpmyadmin are garbled characters, but this problem is not found after we connect to the mysql database using php. The problem is that the content of our database is correct and only the phpmyadmin encoding is incorrect, the following describes how to solve the problem.

Phpmyadmin interface garbled

For example, our Chinese table is garbled. I am using a foreign linux space. it's okay to use it in China. chinese characters in phpmyadmin are garbled. English is correct, but it is displayed normally on the webpage.

If this problem occurs, we do not need to use phpmyadmin, which is a ready-made foreign host. we can download a phpmyadmin file and upload it. this will solve the problem. if not, refer to the following method.

Phpmyadmin garbled solution:

1. because the default encoding of MySQL is latin1, first we need to modify the PHPMyAdmin encoding and conversion, modify the select_lang.lib.php file under the libraries Directory, and run the following code:

[Indent] 'utf-8' => 'utf8', // change it to 'utf-8' => 'latin1', [/indent]

2. Next, modify the code display on the page and run the following code:

[Indent] 'zh-gb2312 '=> array ('zh | chinese simplified', 'Chinese _ simplified-gb2312 ', 'zh '), // modify to 'zh-gb2312-utf-8 '=> array ('zh | chinese simplified', 'Chinese _ simplified-gb2312 ', 'zh'), [/indent]

That is to add-UTF-8 behind the zh-gb2312, so that the page encoding supports UTF-8.

3. first select the zh-gb2312-utf-8 to enter PHPMyAdmin, this time browsing the data of GB2312 encoding is normal, but browsing the data of the UTF-8 is garbled, if you browse the data of the UTF-8, enter the home page, then select the zh-utf-8 in the Language.

Php page Chinese garbled characters

If a program page error occurs, you can refer to one method. in the database, all tables and fields with Chinese characters are encoded using utf8_unicode_ci. Note that both tables and fields must be specified, specify the encoding when connecting to the database. the code is as follows:

Mysqli_query ($ db_conn, "set names utf8"); // specify the encoding of the script to the database: mysqli_query ($ db_conn, "set character_set_client = utf8 "); // specify mysql internal data to disk encoding mysqli_query ($ db_conn, "set character_set_connection = utf8"); // specify mysql connection layer encoding mysqli_query ($ db_conn, "set character_set_results = utf8"); // specifies the encoding of the data result queried by mysql from the disk.

In this way, the page problem is solved.


Article link:

Save this article for favorites!

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.