jeppers Posted August 22, 2008 Share Posted August 22, 2008 i am working on a forum script and i am trying to pull some info from a database. but i keep on getting this message "Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\test\discussion\viewforum.php on line 32" i have looked back through my script and can't seem to see any errors but maybe i am missing something silly. hear is my code please have a look as its completely baffled me. $forumsql = "SELECT * FROM forums WHERE id = " . $validforum . ";"; $forumresult = mysql_query($forumsql); $forumrow = mysql_fetch_assoc($forumresult); echo "<h2>" . $forumrow['name'] . "</h2>"; echo "<a href='index.php'>" . $config_forumsname . " forums</><br /><br />"; //add a link that allows you to add a new topic to this form echo "[<a href='newtopic.php?id= " . $validforum . "'>New Topic</a>]"; echo "<br /><br />"; $topicsql = "SELECT MAX (message.date) AS maxdate, topics.id AS topicid, topics.*, users.* FROM messages, topics, users WHERE messages.topic_id = topic.id AND topics.user_id = user.id AND topics.forum_id ORDER BY maxdate DESC;"; $topicresult = mysql_query($topicsql); $topicnumrows = mysql_num_rows($topicresult); // line 32 this is where the error said it was happening.... if ($topicnumrows == 0) { echo "<table width='300px'><tr><td>No Topics!!</td></tr></table>"; hopefully you can see where i have went wrong thanks Link to comment https://forums.phpfreaks.com/topic/120852-solved-not-sure-where-i-am-going-wrong-but-maybe-you-can-help/ Share on other sites More sharing options...
jeppers Posted August 22, 2008 Author Share Posted August 22, 2008 not sure what to do Link to comment https://forums.phpfreaks.com/topic/120852-solved-not-sure-where-i-am-going-wrong-but-maybe-you-can-help/#findComment-622952 Share on other sites More sharing options...
kenrbnsn Posted August 22, 2008 Share Posted August 22, 2008 Is this topic really "solved"? If not, change <?php $topicresult = mysql_query($topicsql); ?> to <?php $topicresult = mysql_query($topicsql) or die("Problem with the query: $topicsql <br>" . mysql_error()); ?> and see what the error message says. Ken Link to comment https://forums.phpfreaks.com/topic/120852-solved-not-sure-where-i-am-going-wrong-but-maybe-you-can-help/#findComment-622989 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.