<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

解决方案 »

  1.   

    $id=$_GET[id];下面echo $id;  看能取到值吗?  
    如果能取到,你数据库中有该id吗
      

  2.   

    是所有的记录啊!怎么获取! 表是hehe字段 id  names ages times 4个字段! 现在怎么获得所有数据呢
      

  3.   

    去掉后面的where条件不就行了。
      

  4.   

    $result = mysql_query("select * from hehe where id=$id",$conn);
    while ($row = mysql_fetch_object($result))
      {
        echo $row->names;
        echo $row->ages;
        echo $row->times;
     }
      

  5.   

    $result = mysql_query("select * from hehe where id=$id",$conn);
    if($result){
    while ($row = mysql_fetch_object($result))
      {
      echo $row->names;
      echo $row->ages;
      echo $row->times;
     }
    }
      

  6.   


    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>