discorevilo Posted August 21, 2006 Share Posted August 21, 2006 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>[ <a href=\"downloads.php\">Click Here to go back to the main downloads page</a> ]</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"> </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> $version<br> <b>Downloads:</b> $hits<br> <b>Homepage:</b> $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 #7Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in rats.php on line 19 Link to comment https://forums.phpfreaks.com/topic/18199-i-am-so-confuzed-resource-id-7/ Share on other sites More sharing options...
shoz Posted August 21, 2006 Share Posted August 21, 2006 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 https://forums.phpfreaks.com/topic/18199-i-am-so-confuzed-resource-id-7/#findComment-78129 Share on other sites More sharing options...
discorevilo Posted August 21, 2006 Author Share Posted August 21, 2006 :o lol thanks, i fell like a n00b again :P Link to comment https://forums.phpfreaks.com/topic/18199-i-am-so-confuzed-resource-id-7/#findComment-78137 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.