: This article mainly introduces how to solve php Chinese garbled text. if you are interested in PHP tutorials, please refer to it.
$ MySQL_server_name = 'localhost ';
$ Mysql_username = 'root ';
$ Mysql_passWord = '000000 ';
$ Mysql_database = 'Lib ';
$ Conn = mysql_connect ($ mysql_server_name, $ mysql_username, $ mysql_password, $ mysql_database );
$ SQL = "select name, age from mytb ";
PRint ($ conn );
$ Rs = mysql_db_query ("lib", "select * from mytb", $ conn );
Print ("\ n
");
While ($ row = mysql_fetch_object ($ rs )){
Print ($ row-> name. ":". $ row-> age ."
");
}
Mysql_close ($ conn );
?>
Shown as follows:
Resource id #1
Dd: 54
Ddd: 8
?? : 15
??? : 25
?? : 32
Mysql code: utf8, GBK all tried. Mysql font and command line display are correct.
Question added:
Garbled:
??? : 15
??? : 25
?? : 32
In these rows, the database value is Chinese characters, and the question mark is displayed.
Solution:
In $ rs = mysql_db_query ("lib", "select * from mytb", $ conn );
Add
Mysql_query ("set names gb2312"); or mysql_query ("set names gbk ");
The above section describes how to solve php Chinese garbled text, including php Chinese garbled text, and hopes to help those who are interested in PHP tutorials.