Jump to content

Warning: mysql_num_rows(): supplied argument...


Mutley

Recommended Posts

I've fixed this error sooo many times, it must be the early morning today!

 

Anybody see what is causing this? The SQL when printed runs fine in phpmyadmin.

 

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource

 

$sql="SELECT `tid`, `title`, `start_date`, `posts` FROM `ipb_tablestopics` WHERE `forum_id` = '$set_newsarea' ORDER BY `tid` DESC LIMIT $set_newslimit";
$res=mysql_query($sql);
print $sql;
if(mysql_num_rows($res)!=0) {
while(list($tid, $title, $start_date, $posts) = mysql_fetch_row($res)){


print $title.'<br />';
print $start_date.'<br />';
print $posts.'<br />';

$resBody=mysql_query("SELECT `post` FROM `ipb_tableposts` WHERE `topic_id` = '$tid' AND `new_topic` = '1' LIMIT 1");
while($topic=mysql_fetch_array($resBody)){
print $topic["post"];
}
print '<hr />';


}
}else{
echo $e_norows;
}

 

Many thanks.

can't  see anything must be something wrong in the

 

$sql="SELECT `tid`, `title`, `start_date`, `posts` FROM `ipb_tablestopics` WHERE `forum_id` = '$set_newsarea' ORDER BY `tid` DESC LIMIT $set_newslimit";

 

but it does appear you are asking it do do something with num_rows if it is empty maybe its not empty

 

maybe this !=0 should be !==0 ??

That didn't work either.

 

As I've said the variables in the SQL work fine, it prints the correct SQL that works in phpmyadmin - and does bring up results.

 

So you are probably right it's a variable problem but I've tried just doing `tid` and it didn't work either.  ???

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.