I checked the problem of mysql garbled characters on the Internet, set it, restart the mysql service, and continue to use show & nbsp; variables & nbsp; like & nbsp; "% colla % "; show & nbsp; varables & nbsp; like & nbsp; "% char %"; two statements are used to check whether mysql is garbled.
I checked it online, set it, restart the mysql service, and continue to use show variables like "% colla %"; show varables like "% char % "; the two statements are used to query the character set, and the display is also like this. can it be garbled? what is the situation?
And,
Mysql_query ("set names 'gbk'"); // A question mark is displayed when 'gbk' is used, and garbled characters are displayed when 'utf8' is used'Share:
------ Solution --------------------
When no set names xxx is available, the system reads garbled records.
Save the garbled field content to the variable $ s
Then echo base64_encode ($ s );
Post result
------ Solution --------------------
I used to solve this problem:
1. in mysql data, first clear the table to be operated, and then set names gbk. in the gbk state, insert into data (the mysql console adopts the gbk mode ).
2. when the php script inserts data into the database, make sure that our script is in utf8 format. The method is to input the header ("content-type: text/html; charset = utf-8") at the beginning of the script "); at the same time, enter mysql_query ("set names utf8") in the appropriate position of the script ");
You should first modify it according to my method to see how the result is resolved.