fictioncircus Posted March 13, 2008 Share Posted March 13, 2008 Hey guys, we're getting a weird error on our site. I'm the domain admin but not the DBA/coder... he's at work, and we're trying to get the site up ASAP. We would sincerely appreciate any help you could give! Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/fictionc/public_html/menu.php on line 206 Here are the only places in the code where mysql_num_rows() comes in: $sql = "SELECT * FROM newsbox WHERE category='" . $cat . "' ORDER BY news_id DESC"; $news = mysql_query($sql); if (!$news) { die(mysql_error()); } $i = mysql_num_rows($news); while ($i > 0) { $post = mysql_fetch_row($news); displayslug($post); $i = $i - 1; } echo "<hr>"; $storylist = mysql_query($sql); Later in the code... $i = mysql_num_rows($storylist); while ($i > 0) { $st = mysql_fetch_row($storylist); $title = $st[0]; $auth = $st[1]; $desc = $st[2]; $storyid = $st[3]; $storyid = genlink($storyid); echo "<a href=\"" . $storyid . "\">"; echo "<p align=\"center\">"; echo $title; echo "</a><br>"; echo $auth; echo "<br><br><span class=\"datetext\">"; echo $desc; echo "</span><hr>"; $i = $i - 1; } Any help is appreciated. Thanks! -Kevin Carter [email protected] (347) 421-3598 Link to comment https://forums.phpfreaks.com/topic/95979-supplied-argument-is-not-a-valid-mysql-result-resource/ Share on other sites More sharing options...
kenrbnsn Posted March 13, 2008 Share Posted March 13, 2008 Change <?php $sql = "SELECT * FROM newsbox WHERE category='" . $cat . "' ORDER BY news_id DESC"; $news = mysql_query($sql); if (!$news) { die(mysql_error()); } ?> to <?php $sql = "SELECT * FROM newsbox WHERE category='" . $cat . "' ORDER BY news_id DESC"; $news = mysql_query($sql) or die("Problem with the query: $sql<br>" . mysql_error()); ?> and see if it reports any errors. Ken Link to comment https://forums.phpfreaks.com/topic/95979-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-491360 Share on other sites More sharing options...
conker87 Posted March 13, 2008 Share Posted March 13, 2008 Echo your $sql variable before mysql_num_rows. See if where's anything blank within it. Link to comment https://forums.phpfreaks.com/topic/95979-supplied-argument-is-not-a-valid-mysql-result-resource/#findComment-491362 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.