<Html>
<Head>
<Title> </title>
</Head>
<Body>
<? Php (as the mainstream development language)
$ MySQL (the best combination with PHP) _ server_name = localhost;
$ MySQL (the best combination with PHP) _ username = root;
$ MySQL (the best combination with PHP) _ password = 000000;
$ MySQL (the best combination with PHP) _ database = lib;
$ Conn = MySQL (the best combination with PHP) _ connect ($ MySQL (the best combination with PHP) _ server_name, $ MySQL (the best combination with PHP) _ username, $ MySQL (the best combination with PHP) _ password, $ MySQL (the best combination with PHP) _ database );
$ SQL = "select name, age from mytb ";
Print ($ conn );
$ Rs = MySQL (the best combination with PHP) _ db_query ("lib", "select * from mytb", $ conn );
Print ("<br> ");
While ($ row = MySQL (the best combination with PHP) _ fetch_object ($ rs )){
Print ($ row-> name. ":". $ row-> age. "<br> ");
}
MySQL (the best combination with PHP) _ close ($ conn );
?>
Shown as follows:
Resource id #1
Dd: 54
Ddd: 8
?? : 15
??? : 25
?? : 32
MySQL (the best combination with PHP) encoding: utf8 and GBK have been tried. MySQL (the best combination with PHP) 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 (the best combination with PHP) _ db_query ("lib", "select * from mytb", $ conn );
Add
MySQL (the best combination with PHP) _ query ("set names gb2312"); or MySQL (the best combination with PHP) _ query ("set names gbk ");