Jump to content

"Supplied argument is not a valid MySQL result resource"


fictioncircus

Recommended Posts

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

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.