Jump to content

Archived

This topic is now archived and is closed to further replies.

discorevilo

i am so confuzed.. Resource id #7?

Recommended Posts

Im trying to code a smilple downloads page and i am getting a MySQL error that i dont understand can someone help me out, my code is this: (please note the database is connected to threw $conn)
[code]<?
$content = '<br><center><img src="images/downloads.jpg"><br>';
$query = 'SELECT Did,title,name,hits,version,homepage FROM `downloads` WHERE CatID = \'rat\' LIMIT 0, 30';
$result = mysql_query($query, $conn) or die(mysql_error());
$num = mysql_num_rows($result);
echo $result;
if($num == "0") {
$content .= "<br><p align=\"center\">There are no downloads for this category yet";
$content .= "<br>[&nbsp;<a href=\"downloads.php\">Click Here to go back to the main downloads page</a>&nbsp;]</p>";
$content .= "<br><br><br><br>";
// ******NEED TO ASK NABZ ABOUT THE ALL SITE LOGIN*******
//if($useradd == "true" && is_user()) {
//$content .= "<a href=\"downloads.php?cat=vir_worms&op=add\">Click here</a> to submit a file";
//}
} else {
echo '<table width="410" height="271" border="0" cellpadding="1" cellspacing="1">';
echo '<tr>';
$count = 0;
while(list($Did, $title, $name, $hits, $version, $homepage) = mysql_fetch_array($query)) {
echo $name."<br>";
if($cont == "1") {
echo '<td width="46">&nbsp;</td>';
}
if ($count == "2") {
echo '</tr> <tr>';
$count = 0;
}
echo"<td width=\"177\" height=\"90\"><div align=\"center\"><b style=\"text-align: center\">$name</b><br>
        <style type=\"text/css\"><!-- text-align: left; --></style></style><b>Version:</b>&nbsp;$version<br>
        <b>Downloads:</b>&nbsp;$hits<br>
      <b>Homepage:</b>&nbsp;$homepage/div></td>";
$count++;
}
echo '</table>';
}
//----------[ DO NOT EDIT ]----------------------------------------------
  $template->assign_vars(array(
                'CONTENT' => $content,
'DATES' => '2006-2007')
        );
        $template->pparse('body');
?>
[/code]

the error i am getting is:
Resource id #7
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in rats.php on line 19

Share this post


Link to post
Share on other sites
Change this line
[code]
while(list($Did, $title, $name, $hits, $version, $homepage) = mysql_fetch_array($query)) {
[/code]
to
[code]
while(list($Did, $title, $name, $hits, $version, $homepage) = mysql_fetch_array($result)) {
[/code]

Note the change from "mysql_fetch_array($query)" to "mysql_fetch_array(result)"
http://www.php.net/mysql_fetch_array

Share this post


Link to post
Share on other sites

×

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.