I have been writing PHP for more than a year, but the encoding problem is always not well solved. This is my case,
The webpage is completely normal, and Chinese garbled characters are displayed in the phpmyadmin database, either in simplified or traditional Chinese, as long as they are displayed in the following format -... Æ ¸
However, the webpage compiled by myself is displayed completely normal, no matter in Traditional Chinese or simplified Chinese, it will not be garbled.
Of course, my webpage is saved in UTF-8 format, and the mysql_query ("set names 'utf-8'") Statement is added when I read the database, so what you see on the webpage is completely normal. Of course, it is only garbled in phpmyadmin. If you see here, the webpage is garbled, as I said,Save the webpage in Notepad as UTF-8 format, and specify <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/> In the webpage, when reading the database, add mysql_query ("set names 'utf-8'"); no garbled characters will occur. Of course, the database, data table, and fields must also be savedUtf8_general_ci encoded formatThrough the above operations, there will be no garbled characters in the web page. Today I will describe the problem of garbled characters in phpmyadmin,This is a final article about Garbled text. After reading this article, Garbled text will no longer appear in our programs and databases.
After reading the text, you will never see Garbled text on the webpage. However, it takes a day to display Chinese Characters in phpmyadmin, analyze your own code, encoding format, and phpmyadmin encoding format. Search for GG and ask advanced technical staff. Of course, it is better to seek help, after slowly analyzing the encoding problem, I finally found out why I am displaying garbled characters in phpmyadmin. If you want to learn more about the encoding problem, we will not bother you with Garbled text in the future. Check the two differences:Utf8 and UTF-8Don't look at him. He only has one more line. When there is a poor line, it will make your phpmyadmin garbled. Well, analyze your own garbled situation and change the red part, the following are the methods to prevent Garbled text, including the Garbled text in the web page and phpmyadmin:
1. Save all webpages in Notepad as UTF-8 ,:
Note: ANSI is applicable to BIG5 and GBK
2. Specify the <meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/> encoding format on your webpage.
3. Add mysql_query ("set names 'utf8'") to database operations. You can see that it is utf8, not UTF-8. If it is related to the first line, UTF-8 will cause garbled characters in phpmyadmin, I have been writing a program for more than a year, and I have been using UTF-8. It has been in garbled format in phpmyadmin. Now I have switched back to utf8 and finally fixed the problem of Chinese garbled characters in phpmyadmin, after you change it to utf8, all the Chinese characters you read into the database will be garbled. If there is a lot of content, do not change it. At most, phpmyadmin is garbled, the display on the webpage is always normal. Here it is changed to utf8, which will be used for program development in the future. All phpmyadmin will be displayed normally. For the garbled question, 88.
4. The database encoding format isUtf8_general_ci,Table format is alsoUtf8_general_ci,Chinese fields are also usedUtf8_general_ci,See phpmyadmin's load map:
The above isUtf8_general_ci,Then, the field carrying diagram is as follows:
Well, we will not see garbled characters again when we use utf8 encoding for these steps. For Original Articles, please refer to the post on tengma PHP Blog.