<body>
<?php 
$conn=mysql_connect("localhost","root","9909900") or die("数据库服务器连接错误".mysql_error());
mysql_select_db("test",$conn) or die("数据库访问错误".mysql_error());
mysql_query("set names gb2312");
$id=$_GET[id];
$sql="select * from xuesheng where id=$id";
$result= mysql_query($sql);
$info=mysql_fetch_array($result);
?>
<form action="editok.php" name="thisform"  method="post">
 id:  <INPUT name="id "maxLength=25 size=16 value=<?php echo $info[id];?>><br>
 姓名:<INPUT name="name "maxLength=25 size=16 value=<?php echo $info[name];?>><br>
 性别:<input type="radio" name="sex" value="男"<?php if($info[sex]=='男') echo " checked=\"checked\""; ?> >男
       <input type="radio" name="sex" value="女"<?php if($info[sex]=='女') echo " checked=\"checked\""; ?> >女<br>
出生年月:<INPUT maxLength=4 size=4 name=year value=<?php echo $info[year];?>>年 <INPUT maxLength=2 size=2 name=month value=<?php echo $info[month];?>>月
          <INPUT maxLength=2 size=2 name=day value=<?php echo $info[day];?>>日<br>
备注:<textarea cols="50" rows="4" name="note"><?php echo $info[note];?></textarea>
<br>
<input type="submit" name="submit_button"  value="修改" onclick="return check(thisform)"> 
<input type="reset" name="reset_button" value="重置"></form>
</body>
浏览器报Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in E:\web\xuesheng\edit.php on line 47各位高手帮忙看下是什么问题

解决方案 »

  1.   

    把你的
    $sql="select * from xuesheng where id=$id";
    这句打出来!应该是你的sql语句在数据库里执行错误!
      

  2.   

    SQL语句放在数据库中执行有结果吗?
      

  3.   

    baidu、google!将你的sql语句在数据库中运行一下!输出一下$sql,看你的$id有值吗……
      

  4.   


    $conn=mysql_connect("localhost","root","9909900") or die("数据库服务器连接错误".mysql_error());
    mysql_select_db("test",$conn) or die("数据库访问错误".mysql_error());
    mysql_query("set names gb2312");
    if(isset($_GET[id])){//判断是否存在在执行查询
    $id=$_GET[id];
    $sql="select * from xuesheng where id=$id";
    $result= mysql_query($sql);
    $info=mysql_fetch_array($result);
    }
      

  5.   


    我的$id 是前面有个页面带过来的,前面页面的代码     <?php
    $link=mysql_connect("localhost","root","9909900") or die("数据库连接失败".mysql_error());
    mysql_select_db("test",$link);
    mysql_query("set names gb2312");
    $sql=mysql_query("select * from xuesheng");
    $info=mysql_fetch_array($sql);
    if ($_POST[Submit]=="查询"){
    $name=$_POST[name];
    $sql=mysql_query("select * from xuesheng where name like '%".trim($name)."%'"); //如果选择的条件为"like",则进行模糊查询
    $info=mysql_fetch_array($sql);
    }
    if($info==false){          //如果检索的信息不存在,则输出相应的提示信息
        echo "<div align='center' style='color:#FF0000; font-size:12px'>对不起,您检索的学生信息不存在!</div>";
    }
     do{
      ?>
                    <tr align="left" bgcolor="#FFFFFF">
                      <td height="20" align="center"><?php echo $info[id]; ?></td>
                      <td >&nbsp;<?php echo $info[name]; ?></td>
                      <td align="center"><?php echo $info[sex]; ?></td>
                      <td align="center"><?php echo $info[year]."年".$info[month]."月".$info[day]."日"; ?></td>
                      <td align="center">&nbsp;<?php echo $info[note]; ?></td>
                       <td align="center"><a href="edit.php?id=<?php echo $info[id];?>"><img src="images/update.gif" width="20" height="18" border="0"></a></td>
                    </tr>
                    <?php
    }
    while($info=mysql_fetch_array($sql));
    ?>
      

  6.   

    $info=mysql_fetch_array($result);这句改一下:while($info=mysql_fetch_array($result))
    {
         //这里拼接一下数组
    }即可
      

  7.   

    最可能的原因就是$id=$_GET[id];没有取到值,导致结果集为NULL,建议使用isset判断一下,$id=isset($_GET[id])?$intval($_GET[id]):1;这样会安全
      

  8.   

    如果传值没问题的话,$id换成别的变量。还有我们尽量不要使用mysql的保留字来命名变量。
      

  9.   

    直接echo出查询语句,看看是不是和你想象的一样。问题多半就在于此了。不然就是数据库字段什么地方打错了。