当前位置: 代码迷 >> PHP >> Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resourc解决办法
  详细解决方案

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resourc解决办法

热度:450   发布时间:2016-04-28 20:20:36.0
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resourc
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
.STYLE1 {font-size: 12px}
.STYLE2 {font-size: 12px; color: #000066; }
.STYLE3 {color: #000066;
font-weight: bold;
font-size: 18px;
}
-->
</style>
</head>

<body>
<p>&nbsp;</p>

<?php
    include("conn.php");
    $SQL="SELECT * FROM `liuyanban` order by id desc";
    $query=mysql_query($SQL);
  
    
$total=mysql_num_rows($query);
$pagesize=3;
$end_page=ceil($total/$pagesize);
$page = $_GET['page']; //当前页
if($page<=0)
{
$page =1;
}

if($page>$end_page)
{
$page=$end_page;
}
$start = ($page- 1)*$pagesize;
$sql = "select * from liuyanban limit $start, $pagesize ";

//mysql_query("set names 'GBK'");
$ros = mysql_query($sql,$connect);
?>

<?php

echo "留言表";
echo "<br>";
echo "当前第[$page]页,共[$end_page]页";
if($page==1)
{
 
?>
  首页
  <?php
}else
{
?>
  <a href="admintxl2.php?page=1" >首页</a>
  
  
  <?php
}
?>
  
  <a href="admintxl2.php?page=<?php echo ($page-1);?>" >上一页</a>
  <a href="admintxl2.php?page=<?php echo ($page+1);?>" >下一页</a>
  
  <?php
if($page==$end_page)
{
?>
  尾页
  <?php
}else
{
?>
  <a href="admintxl2.php?page=<?php echo $end_page ;?>">尾页</a>
  <?php
}
?>
</p>

 
</table>
 </center>
   
</div>

<table width="750" height="158" border="0" align="center" cellpadding="0" cellspacing="1" bordercolor="#FFFFFF" bgcolor="#CCCCCC">
    <tr>
      <td height="25" colspan="6" align="center" bgcolor="#0099CC"><span class="STYLE3">会员表</span></td>
    </tr>

    <tr>
      <td width="14%" height="44" align="center" bgcolor="#FFFFFF"><div align="center" class="STYLE2">姓名</div></td>
      <td width="15%" align="center" bgcolor="#FFFFFF"><div align="center" class="STYLE2">邮箱</div></td>
      <td width="46%" align="center" bgcolor="#FFFFFF"><div align="center" class="STYLE2">留言内容</div></td>
      <td width="25%" align="center" bgcolor="#FFFFFF"><div align="center" class="STYLE2">操作</div></td>
    </tr>
    <?php
   while ($row=mysql_fetch_array($ros)){
   ?>
    <tr>
      <td width="14%" height="44" align="center" bgcolor="#FFFFFF"><div align="center" class="STYLE1"><?=$row['name']?></font></a></div></td>
      <td width="15%" align="center" bgcolor="#FFFFFF"><div align="center" class="STYLE1"><?=$row['email']?></div></td>
      <td width="46%" align="center" bgcolor="#FFFFFF"><div align="center" class="STYLE1"><?=$row['liuyan']?></font></a></div></td>
     <td align="center" class="STYLE1" bgcolor="#FFFFFF"><a href="admintxlup.php?id=<?php echo $row['id']?>">修改</a> <a href="admintxldel2.php?id=<?php echo $row['id']?>">删除</a></td>
    </tr>
   <?php    
   }
   ?>
  </table>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="admintxlfb.php" >增加会员表记录</a> </p>

</body>
</html>
  相关解决方案