Problem: "Page display noon" and "Database View Chinese" there is always a garbled, or "there is always a part of the page in Chinese garbled"
After the Phpstudy has been installed, the database has been modified with alter to encode the utf8! At that time, the encoding of the Web page is normal, so I did not mind thought it would! Until later found: The page is not garbled when the Chinese language, but in the database to view the Chinese language is garbled! Also more strange is, I do an e-commerce site, I found the first level menu in Chinese display "Summer clothing"-"summer" display Normal, "clothing" garbled! In fact, this is only garbled, because I use the command to modify its display encoding method, the data display is normal, but the Web page is not normal, do not change, the Web page can be normal display Chinese! This is my headache. Now solve the problem, summarize the record, if there is inaccurate, please advise, thank you!
Solve:
1) Idea: garbled situation may be caused by the following conditions:
(1) When the editing file is saved with the encoding method is inconsistent with the opening--open the file display code, but I think it should not affect the operation of the file;
(2) File display settings are encoded in the same way as when the database is created--the file is garbled after it runs or the database is garbled.
(3) The file display settings and the database settings are partly different in encoding--may appear above my situation
"Face the first case: Save the original editor again for UTF8; the second case: Modify the encoding of the data with the ALTER command, or delete the database and re-import"
2) Principle:
In the MySQL database, the default encoding is LATIN1, is not supported in Chinese, to support the Chinese will need to change the default encoding of the database to UTF8 or GBK.
First look at how the database is encoded: show variables like ' character% '; show the following "This display is I have modified to UTF8":
Or use: Show variables like ' collation% '; View database encoding
As long as the above three connection, database, server three encoding way will not garbled!
3) Workaround:
Open MySQL configuration file: Mysql.ini, modify two places:
default-character-set=xxx--modifies the database default character set encoding, but does not include the database server encoding "that is, not including: Collation_server"
character-set-server=xxx--Modifying the encoding of the database server
Only need to change the two to the same UTF8 or GBK on it! "For the different characters, UTF8 and GBK occupy the same storage space, the details can be Google"
For the database character set encoding method of some commands, we can look at the blogger "Scarlet Setting Sun column" of this article, there are said!
Links:http://blog.csdn.net/wangjun_pfc/article/details/3827631http://blog.csdn.net/wangjun_pfc/article /details/3827631
MySQL database "local" garbled