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

[email protected]

(347) 421-3598

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

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.