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 kevinandrewcarter@gmail.com (347) 421-3598 Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.