打开index.php时就出现Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\address3\index.php on line 31#这个错误,但看了下index.php下的31也找不出什么错来,  $rows=mysql_num_rows($result);  
把这些代码都贴出来,可能很长全部地址簿分为index.php   modify_form.php   update.php   delete.php                
              content.php add_from.php   add.php
             include文件夹包含了day.inc head.inc tail.inc
               图片文件夹就先不管了。
#index.php
<?php 
    session_start();
?>
<html>
<head>
<title>清风同学录</title>
<meta  http-equiv="content-type" content="text/html; charset=gb2312">
<style>
    body {  font-family: "verdana"; font-size:"9pt" };
p    { }
table {font-size: 9pt }
td   { font-family: "verdana";  font-size: "9pt"; line-height:"14pt"; letter-spacing="1pt" }
a:link {text-decoration: none ; color: blue}
a:visist {text-decoration:none; color:yellow}
a:hover  {text-decoration:underline; color:green}
</style>
</head>
<body topmargin=3 bgcolor="#ffffff">
   <div>
      <center>
    <?php
    
$connect=mysql_connect("localhost","root","123456");
              mysql_select_db("mysite",$connect);
$query="SET NAMES 'gb2312'";
$result=mysql_query($query);    //设置查询字符集,保证能够正确显示汉字            $query="select * from address";
$result=mysql_query($query); $rows=mysql_num_rows($result);    include("include/head.inc");
?>
<table border="1" width=90% cellspacing=0 cellpadding=0 bgcolor="#e4e4e4" bordercolorlight="#c2c2c2"                   bordercolordark="#ffffff">
            <tr>
  <th width="10%" >姓&nbsp;&nbsp;&nbsp;&nbsp;名</th>
  <th width="25%" >地&nbsp;&nbsp;&nbsp;&nbsp;址</th>
  <th width="20%" >邮&nbsp;&nbsp;&nbsp;&nbsp;箱</th>
  <th width="10%" >O&nbsp;I&nbsp;C&nbsp;Q</th>
  <th width="20%" >联系方式</th>
  <th width="15%" >操&nbsp;&nbsp;&nbsp;&nbsp;作</th>
</tr>

 <?php
      for ($i=0; $i<$rows;$i++)
  {
  mysql_data_seek($result,$i);
  $data=mysql_fetch_array($result);
  
  $id=$data['Id'];
  $name=$data['Name'];
  $address=$data['Address'];
  $email=$data['Email'];
  $oicq=$data['Oicq'];
  $phone=$data['Phone'];   echo "<tr>";
  ?>
    <td width="10%" align="center"> <?php echo $name; ?> </td>
<td width="25%" align="center"> <?php echo $address; ?> </td>
<td width="20%" align="center"> <?php echo $email;  ?>  </td>
<td width="10%" align="center"> <?php echo $oicq;   ?>   </td>
<td width="20%" align="center"> <?php echo $phone;  ?>  </td>
<td width="15%" align="center"> 
   <a href="content.php?id=<?php echo $id; session_register("{$id}"); ?>" > <img src="picture/content.gif" border="0"          alt="详细内容"  width="13" height="12"></a>&nbsp;&nbsp;
   <a href="modify_form.php?id=<?php echo $id; session_register("{$id}"); ?>" >  <img src="picture/modify.gif" border="0"           alt="修 改" width="13" height="11"></a>&nbsp;&nbsp;
   <a href="delete.php?id=<?php echo $id; session_register("{$id}"); ?>"  >  <img src="picture/delete.gif" border="0"           alt="删除" width="13" height="11"></a>
</td>
</tr>
<?php 
  }
  mysql_close($connect);
 
?>
        </table>
  </center>
   </div>
   <?php
      include("include/tail.inc");
   ?>
   </body>
   </html>

解决方案 »

  1.   

    #update.php
    <?php 
      echo "<meta http-equiv=\"refresh\" content=\"0;url=index.php\">";
      echo "<meta http-equiv=\"content-type\" content=\"text/html;charset=gb2312\">";      $connect=mysql_connect("localhost","root","123456");
           mysql_select_db("mysite",$connect);
          $query="SET NAMES 'gb2312'";
          $result= mysql_query($query);
          $query="select * from mysite.address where Id='$id'";
          $result=mysql_query($query);
           mysql_data_seek($result,0);
          $data=mysql_fetch_array($result);  $path="d:/web/picture/".$_FILES['up_picture']['name'];
      if($up_picture!="")
      {    unlink($data['Picture']);
           copy($up_picture,$path);
          $picture=$path;
      }
      else
      { 
      $picture="d:/web/picture/mypo.jpg";
      }  $query="update mysite.address set Name='$name' ,Favorate='$favorate',Address='$address',Email='$email',Word='$word',Oicq='$oicq',Phone='$phone',Picture='$picture'where Id='$id'";
      $result=mysql_query($query);
       mysql_close($connect);
    ?>
      

  2.   

    select * from address这个sql可能没查出东西来,检查下表名是否正确。
      

  3.   

    echo 下SQL查询语句,把它复制到PHPMYADMIN中看下有没有结果,或者对下字段名有没有错
      

  4.   

    mysql_num_rows(): supplied argument is not a valid MySQL result resource in 
    这句看出你的mysql_num_rows使用的不是有效资源。即该函数的参数有错误
      

  5.   

    $result=mysql_query($query);
    if ($result)
    {
        $rows=mysql_num_rows($result);
    }
      

  6.   

    楼上的能不能把你的代码给全呀,
    我现在index.php的能正常运行,
    可是没有其他部分的不好弄呀!!
    我的email:[email protected]