Jump to content


Photo

i am so confuzed.. Resource id #7?


  • Please log in to reply
2 replies to this topic

#1 discorevilo

discorevilo
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 21 August 2006 - 03:33 PM

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)
<?
$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');
?>

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

#2 shoz

shoz
  • Staff Alumni
  • Advanced Member
  • 600 posts

Posted 21 August 2006 - 03:46 PM

Change this line
while(list($Did, $title, $name, $hits, $version, $homepage) = mysql_fetch_array($query)) {
to
while(list($Did, $title, $name, $hits, $version, $homepage) = mysql_fetch_array($result)) {

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

#3 discorevilo

discorevilo
  • Members
  • Pip
  • Newbie
  • 9 posts

Posted 21 August 2006 - 04:10 PM

:o lol thanks, i fell like a n00b again  :P




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users