sql函数mysql_num_rows()老出错说找不到有效值?
Warning:mysql_num_rows():suppliedargumentisnotavalidMySQLresultresourceinD:\wamp\www\...
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in D:\wamp\www\Discussion Forum\viewforum.php on line 30
语句
$topicsql="select MAX(messages.date) as maxdate, topics.id as topicid,topics.*,users.* from messages,topics,users where messages.topic_id =topics.id and topics.user_id=users.id and topics.forum_id=".$validforum."GROUP BY messages.topic_id ORDER BY maxdate DESC;"; $topicresult=mysql_query($topicsql);
$topicnumrows=mysql_num_rows($topicresult); 展开
语句
$topicsql="select MAX(messages.date) as maxdate, topics.id as topicid,topics.*,users.* from messages,topics,users where messages.topic_id =topics.id and topics.user_id=users.id and topics.forum_id=".$validforum."GROUP BY messages.topic_id ORDER BY maxdate DESC;"; $topicresult=mysql_query($topicsql);
$topicnumrows=mysql_num_rows($topicresult); 展开
2个回答
展开全部
试试把最后一句改为$topicnumrows=mysql_num_rows($result);
更多追问追答
追问
可是又没有$result,改了还是错啊,感觉是sql查询错了,但我自己找不出来错哪了
追答
把 $topicresult=mysql_query($topicsql); 改成 $topicresult = @mysql_query($topicsql) or die(mysql_error); ,执行看一下错误信息,这样你就可以知道你sql语句哪里出现错误了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询