<title></title>
<body>
<?php
$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<br>");
while ($row = Mysql_fetch_object ($rs)) {
Print ($row->name. ":". $row->age. " <br> ");
}
Mysql_close ($conn);
?>
The display is as follows:
Resource ID #1
dd:54
Ddd:8
?? : 15
??? : 25
?? : 32
MySQL code: UTF8,GBK have tried. MySQL font and command line display are correct.
question added:
Garbled:
??? : 15
??? : 25
?? : 32
In these lines, the value in the database is Chinese characters. The question mark is displayed.
Solution:
In $rs=mysql_db_query ("Lib", "select * from MYTB", $conn);
Before adding
mysql_query ("Set names gb2312") or mysql_query ("Set names GBK");
please contact the site, timely note your name. Contact Email: edu#chinaz.com (change # to @).