I encountered the problem of garbled characters when using PHP+MYSQL. The solution:
Add SET NAMES UTF8 after mysql_connect to eliminate garbled characters in the UTF8 database. For GBK database, use SET NAMES GBK. The code is as follows:
1 $mysql_mylink = mysql_connect($mysql_host, $mysql_user, $mysql_pass);
2 mysql_query("SET NAMES 'GBK'");
The database character set is utf-8
Use this for the connection statement
1 mysql_query("SET NAMES 'UTF8'");
2 mysql_query("SETCHARACTERSET UTF8");
3 mysql_query("SET CHARACTER_SET_RESULTS=UTF8'");