Jump to content

i am so confuzed.. Resource id #7?


discorevilo

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
Link to comment
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
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.