Fix phpmyadmin garbled characters and support gb2312 and UTF-8

Source: Internet
Author: User

Fix phpmyadmin garbled characters and support gb2312 and UTF-8

Many PHP fans in the group have been plagued by phpmyadmin garbled characters. since I had mysql-front, I seldom used phpmyadmin. however, each connection to the remote host is slow. the operation is inconvenient. today is a bit of time, so I will try the latest version.

First, describe my database usage:

Phpmyadmin version 2.7.0-pl1
(If you use another version, it may be different. Please modify it or download phpmyadmin 2.7.0-pl1 here)

Mysql 5.0.11-beta-nt

I used to use the GB2312 encoding method to directly write data to the database. The character set is mysql's default latin1.

PHP5 after I write the program are switched to the UTF-8 encoding method, but also directly read and write. So the character set is also the default mysql latin1

When I use PHP to operate dataNoThe following statements have been used:
SET character_set_client = utf8;
SET character_set_results = utf8;
SET character_set_connection = utf8;

Okay. Let's get started.

Decompress the downloaded ZIP package to the www directory and open the folder... after a long time, the configuration file names are changed from config. inc. php to config. default. php.

I modified the following code:

31 rows
$ Cfg ['pmaabsoluteuri '] = 'HTTP: // localhost/phpMyAdmin-2.7.0-pl1 /';

45 rows
$ Cfg ['blowfish _ secret'] = 'eas ';

71 rows
$ Cfg ['servers'] [$ I] ['auth _ type'] = 'cooker'; // Authentication method (config, http or cookie based )?

Then the browser opens http: // localhost/phpMyAdmin-2.7.0-pl1/use root to log on. language is the default chinese simplified (zh-utf-8)

Browse a UTF-8 table. garbled.

The html source code is viewed, charset = UTF-8

View libraries/select_lang.lib.php

Row 3: 'utf-8' => 'utf8 ',

I use the default latin1. So I want to change it to latin1. save it and refresh it.

Go to a library that was previously input using GB2312 encoding. It is garbled.

Exit. log in with chinese simplified (zh-gb2312). view it everywhere. garbled.

Find libraries/select_lang.lib.php

Row 3: 'gb2312' => 'gb2312 ',

Change gb2312 to latin1. save, refresh, But not. The same is true.

I am wondering. I checked the html source code, charset or UTF-8. No, it is normal to test for GB2312.

Inadvertently in the language drop-down menu on the home page, the chinese simplified (zh-gb2312) column was not found at login .()

I don't know. Check whether the list items are completed by UTF-8. The problem should be solved here.

Find the zh-gb2312 corresponding to libraries/select_lang.lib.php and add "-UTF-8" to it"

This time, I checked the html source code. charset is GB2312.

How can we switch between the two languages?
I tried to go back to the UTF-8-encoded table. That's right, it's garbled.

Go to the home page. language drop-down menu select zh-utf-8. Then look at, OK.

Try to modify and add new data. There are no garbled characters.

End: My idea is to compare the character set of mysql with the character set of html.

Last reminder:

If you have used the following statements when operating the table:
SET character_set_client = utf8;
SET character_set_results = utf8;
SET character_set_connection = utf8;

Then, when you modify libraries/select_lang.lib.php, it may be different. Try several more methods.

Reprinted, please indicate the source is www.phpv.net

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.