The simplest way is to programmatically access MySQL by adding a line of code: mysql_query ("SET NAMES ' GBK '");
1.PHP page language itself is not the appropriate encoding type, when you write directly in the script in Chinese is certainly garbled, needless to say, the database.
Workaround: Select ' UTF8 ' or ' gb2312 ' so that the client browser automatically selects and displays the correct Chinese display. Note: ' UTF8 ' or ' gb2312 ' can be displayed correctly in Chinese.
2. The encoding type in the database MySQL is incorrect.
Workaround: When creating the database, MySQL character set select ' UTF8 ', MySQL connection proofing select Utf8_general_ci, so create the database used to store Chinese certainly no problem, otherwise, your Chinese first in MySQL is garbled, Not to expect it will give you the correct display in the PHP page.
3. It is related to the normal script editing environment.
For example, some of the content is written in Word, some are written in Notepad, some with EditPlus, Ultraplus and other text editor. Sometimes I write Chinese directly in the DW,
Workaround: Try to use the same editor as possible. If it is a copy of the existing content, it is recommended to use the Ultraplus encoding conversion function to convert it to UTF8 or gb2312. It doesn't matter what type it is converted to, it's critical that the code in your PHP Web application be consistent.
PHP read MySQL Chinese data garbled solution