<body>
<?php
$conn=mysql_connect("localhost","root","")or die("数据库错误,error");
mysql_select_db("test",$conn)or die("error");
mysql_query("set names utf8");
$id=$_GET[id];
$sql=mysql_query("select * from hehe where id=$id");
$row=mysql_fetch_object($sql);
do{
echo $row->names;
echo $row->ages;
echo $row->times;
}
while(mysql_fetch_object($sql));
?>
</body>
--------------------------------
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in E:\wamp\www\show.php on line 15Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in E:\wamp\www\show.php on line 21
<?php
$conn=mysql_connect("localhost","root","")or die("数据库错误,error");
mysql_select_db("test",$conn)or die("error");
mysql_query("set names utf8");
$id=$_GET[id];
$sql=mysql_query("select * from hehe where id=$id");
$row=mysql_fetch_object($sql);
do{
echo $row->names;
echo $row->ages;
echo $row->times;
}
while(mysql_fetch_object($sql));
?>
</body>
--------------------------------
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in E:\wamp\www\show.php on line 15Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in E:\wamp\www\show.php on line 21
如果能取到,你数据库中有该id吗
while ($row = mysql_fetch_object($result))
{
echo $row->names;
echo $row->ages;
echo $row->times;
}
if($result){
while ($row = mysql_fetch_object($result))
{
echo $row->names;
echo $row->ages;
echo $row->times;
}
}
body>
<?php
$conn=mysql_connect("localhost","root","")or die("数据库错误,error");
mysql_select_db("test",$conn)or die("error");
mysql_query("set names utf8");
$id=$_GET[id];
$sql=mysql_query("select * from hehe where id=$id");
$row=mysql_fetch_object($sql);
do{
echo $row->names;
echo $row->ages;
echo $row->times;
}
while(mysql_fetch_object($sql)); // 不是$sql ,而是 $row
?>
</body>