Jump to content

[SOLVED] not sure where i am going wrong but maybe you can help


jeppers

Recommended Posts

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

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.