MYSQL数据传送时为何会出现这样的错误提示?
Warning: Supplied argument is not a valid MySQL result resource in c:\apache\htmlphp\11\11\list.php on line 21
list.php的代码如下:
<html>
<head>
<title></title>
</head>
<body bgcolor="#004784" text="#ffffff" >
<?php
if (isset($title)and isset($writer) and isset($text)) {
$con=mysql_connect("localhost","dcwang","dcwang");
mysql_select_db("bbs");
$query="insert into note(title,writer,text,id,created) values ('$title','$writer','$text',null,'$created')";
$stmt = mysql_query($query,$con);
mysql_close($con); }
$con=mysql_connect("localhost","dcwang","dcwang");
mysql_select_db("bbs");
echo "<table border='1' width='800' height='100'>";
$query="select title,writer,text,id,created ";
$query.="from note ";
$res=mysql_query("$query",$con);
if (empty($offset)) {
$offset=0;}
$number=mysql_num_rows($res); \\\\\\\\\\\\第21行
$see=$offset/15+1;
$all=$number/15;
$all=(int)$all+1;
$query="select title,writer,text,id,created ";
$query.="from note order by created limit $offset,15 ";
$result=mysql_query("$query",$con);
echo "<br>";
echo "<tr>";
echo "<tr>";
echo "<tr>";
echo "<tr>";
echo "<center><font size='3'>本讨论区有 $number 条贴子:(第 $see 页,共 $all 页)</font></center>";
echo "<td align='left'><font size='2'>序号</font></td>";
echo "<td align='left'><font size='2'>主题</font></td>";
echo "<td align='left'><font size='2'>作者</font></td>";
echo "<td align='left'><font size='2'>时间</font></td>";
echo "</tr>
<td>";?>
<form method="post" action="bbs.php">
<?php
$ttt=0;
while ($r=mysql_fetch_row($result)) { \\\\第43行
$ttt++;
$title=$r[0];
$writer=$r[1];
$text=$r[2];
$id=$r[3];
$created=$r[4];
echo "<tr>"; ?>
<?php
echo "<td align='left'><font size='2'>$id</font></td>";
if ($title=='')
echo "<td align='center'><font size='2'>--</font></td>";
else
echo "<td align='left'><font size='2'><a href=text.php?id=$id>$title</a></font></td>";
if ($writer=='')
echo "<td align='center'><font size='2'>--</font></td>";
else
echo "<td align='left'><font size='2'>$writer</font></td>";
echo "<td align='left'><font size='2'>$created</font></td>";
echo "</tr>";}
echo "</table>";
mysql_close($con);
?>
<br>
<input type=submit name=submit value=发表文章>
</form>
<?php
if($offset>0)
{
$preoffset=$offset-15;
echo "<a href=list.php?offset=$preoffset>前一页</a> \n";}
if (($offset+15)<$number) {
$newoffset=$offset+15;
echo "<a href=list.php?offset=$newoffset>下一页</a> \n";
}
?>
</body>
</html>