<html>
<head>
<title></title>
</head>
<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);
? >
Show as follows:
Resource Id #1
Dd:54
Ddd:8
? ? : 15
? ? ? : 25
? ? : 32
Mysql encode: Utf8, GBK has tried. Mysql Font and command travel show correct.
The problem is additional:
Random code:
? ? ? : 15
? ? ? : 25
? ? : 32
These a few, the value in the database is a Chinese character. Show those who come out is interrogation.
Settle way:
In $rs=mysql_db_query(”lib” , “Select * From Mytb” , $conn);
Add in front
Mysql_query(”set Names Gb2312″); or Mysql_query(”set Names Gbk”);
Ask an author to contact this station, seasonable annotations your full name. Contact mailbox: EDu#chinaz.com (# instead @ ) .
