Garbled problem 1: When PHPmyAdmin is used to operate MySQL databases, Chinese characters are displayed normally, but when MySQL DATA is displayed on the PHP webpage, all Chinese characters are changed? .
Symptom: it is normal to use PHPmyAdmin to input Chinese characters. But when MySQL DATA is displayed on the PHP webpage, the Chinese characters become? And how many Chinese characters are there? .
Cause: no code is used on the PHP webpage to tell MySQL which character set to output Chinese characters.
Solution:
1. Set the header encoding for the webpage file <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
2. When saving the PHP page, use UTF-8 encoding to save it. You can use notepad or convertz802 to convert the file.
3. When creating a database in MYSQL, the database selects UTF-8 encoding, both character sets are set to utf-8_unicode_ci (Unicode (multilingual), case-insensitive ),
In the library, table sorting is set to utf-8_general_ci.
The sorting of each field in the table is set to utf-8_general_ci
4. When PHP connects to the database, that is, after mysql_connect (), add
// Set the data Character Set UTF-8
Mysql_query ("set names 'utf8 '");
Mysql_query ("set character_set_client = utf8 ");
Mysql_query ("set character_set_results = utf8 ");
Note that it is utf8, not UTF-8.
If your webpage code is gb2312, It is set names GB2312. However, editors strongly recommend that web code, MySQL Data Table Character Set, PHPmyAdmin all use UTF-8.
The above four points can implement full-site UTF-8 encoding, and there will be no Chinese garbled characters in the database.
Garbled problem 2: an error occurs when you use PHPmyAdmin to input data.
Solution: this is a setup problem. Install the latest PHPmyAdmin or Appserv, open PHPmyAdmin, MySQL Character Set: UTF-8 Unicode (utf8); MySQL connection proofread should be utf8_unicode_ci; when creating a new database, sort the column as utf8_unicode_ci. UTF-8 is also recommended for Web character sets. UTF-8 is an international standard and a trend.
Garbled problem 2: The MySQL Data Table developed on the local machine is tested to be normal on the local machine, but the PHPmyAdmin file provided by the website space provider fails to be uploaded. Especially when using PHP space outside China.
Solution: First, check the PHPmyAdmin Character Set provided by the website Space Provider, and confirm that the data table you created is the same code as that of the service provider. MySQL does not support gb2312 in foreign countries, and even the latest version of Apache does not support gb2312. If the encoding is not uniform, you can recreate the data table. Of course, the international standard UTF8 is used.
By smallacmer