How to debug this problem?
Posted: Thu Apr 17, 2008 4:56 pm
I have the following replylist.php code, when I try to display on the page I got the error message"Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in C:\AppServ\www\htdocs\replylist.php on line 16." But it seems like nothing wrong with line 16, so can anyone help me with that, thanks!
Code: Select all
<!--sys_conf.inc:------------------------------>
<?php
$DBHOST="localhost";
$DBUSER="root";
$DBPWD="12345";
$DBNAME="guestbook";
?>
Code: Select all
<!--replylist.php:--------------------->
<?php
require_once("sys_conf.inc");
//Initial
$one_page_line=10; //Max_Page
$reply_content=array();
$link_id=mysql_connect($DBHOST,$DBUSER,$DBPWD);
mysql_select_db($DBNAME);
$str="select content from reply where bookid =".$_GET["recordid"];
$result=mysql_query($str,$link_id);
$i=0;
while(list($con)=mysql_fetch_row($result))
{
$reply_content[$i]=$con;
$i++;
}
mysql_close($link_id);
$count =count($reply_content);
?>
<html>
<head>
<title>Review for reply</title>
</head>
<body>
<?php include "head.html"?>
<table width="68%" border="0">
<tr>
<td>
<?php
$int_page_count=$count;
$int_page_num=ceil($int_page_count/$one_page_line);
echo "<font color=#CC33FF>page separate:";
for ($i=1;$i<=$int_page_num;$i++)
{
echo "<a href=booklist.php?recordid=".$_GET["recordid"]."&page=$i>".$i."</a> ";
}
echo "</font>";
?>
</td>
<td><p align=right>Total<font color=red><?echo "$count"?></font>Messages</p></td>
</tr>
</table>
<table width="68%" border="0" align="center">
<?
if (!isset($page) or $page=="")
$page=1;
$text="";
$begin_line=$int_page_count-($page-1)*$one_page_line;
if ($begin_line<$one_page_line)
$one_page_line=$begin_line;
for ($j=$begin_line;$j>($begin_line-$one_page_line);$j--)
{
print_r ($reply_content[$j-1]);
}
?>
</table>
<p align=center><a href="#" onclick=history.back()>Return</a></p>
</body>
</html>