Solve phpMyAdmin garbled, support gb2312 and Utf-8

Source: Internet
Author: User
Tags character set config log mysql mysql version php and phpmyadmin
Solve
Solve phpMyAdmin garbled, support gb2312 and Utf-8

Many PHP enthusiasts in the group have been plagued by phpmyadmin garbled problems. I've been using phpMyAdmin a lot since I've had mysql-front. But each time you connect to a remote host, it's slower. This is a bit of a time, and it's the latest version to study.

Let me start by explaining my database usage:

phpMyAdmin version 2.7.0-pl1
(If you use another version, may be different, please compare or download phpMyAdmin 2.7.0-pl1)

MySQL version MySQL 5.0.11-beta-nt

I used to use GB2312 encoding, write directly to the database, the character set is the MySQL default latin1

PHP5 after I wrote the program is to use the UTF-8 encoding method, but also directly read and write. So the character set is also the test of MySQL default latin1

I did not use the following statement when manipulating data in PHP:
SET character_set_client = UTF8;
SET character_set_results = UTF8;
SET character_set_connection = UTF8;

All right, let's go.

Unzip the downloaded zip package to the WWW directory and open the folder ... Long time no see, the configuration filename has changed from config.inc.php to config.default.php.

I modified the following code:

31 lines
$cfg [' pmaabsoluteuri '] = ' http://localhost/phpMyAdmin-2.7.0-pl1/';

45 lines
$cfg [' blowfish_secret '] = ' this ';

71 lines
$cfg [' Servers '] [$i] [' auth_type '] = ' cookie '; authentication method (config, HTTP or cookie based)?

The browser then opens http://localhost/phpMyAdmin-2.7.0-pl1/to log on using root. Language is the default Chinese simplified (zh-utf-8)

Browse a UTF-8 table. garbled.

View the HTML source code, CHARSET=UTF-8

View his language selection file libraries/select_lang.lib.php

263 lines ' utf-8 ' => ' UTF8 ',

I'm using the default latin1 So, here's to change the exam to latin1. Change to save, refresh. Success

Go to a library that was previously entered with GB2312 encoding. It's garbled.

Exit. Log in as Chinese Simplified (zh-gb2312). Look around. garbled.

Find libraries/select_lang.lib.php like the one above.

250 lines ' gb2312 ' => ' gb2312 ',

Change the gb2312 to latin1. save, refresh. It doesn't work. Still the same.

I'm wondering. View the HTML source code, CharSet or Utf-8. No, the test is GB2312 is normal.

Inadvertently in the language Drop-down menu in the home page, found no login Chinese Simplified (zh-gb2312) this column. (Figure below)

Puzzled, carefully a pair, list items are Utf-8 end. The problem is here.

Find the corresponding zh-gb2312 in the libraries/select_lang.lib.php and add a "-utf-8" behind it.

This time there is. View the HTML source code, CharSet is GB2312.

How do you convert between two languages?
I tried to go back to the UTF-8 encoded table. Yes, it's garbled.

Go to the home page. Language the Drop-down menu to select Zh-utf-8. Look again, OK.

Try to modify and add new data. There's no more garbled.

End: My idea is to use HTML charset against MySQL's CharSet.

Last reminder:

If you have used the following statement when you manipulate the table:
SET character_set_client = UTF8;
SET character_set_results = UTF8;
SET character_set_connection = UTF8;

Libraries/select_lang.lib.php may be different when you modify it. Try a few more ways. There will be a different harvest.



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.