marcus Posted November 25, 2006 Share Posted November 25, 2006 I am making a news sytem, and on the index it would echo the news. Now, I have two rows in the news table right now, but it's only showing one of them and then i get an error:[code]Warning: mysql_fetch_array(): 7 is not a valid MySQL result resource in /home/neoblob/public_html/cms/index.php on line 20[/code][code]<? include('header.php'); ?><?php$page = $_GET[page];$fetch = "SELECT * FROM news ORDER BY `id` DESC"; $fet1 = mysql_query($fetch) or die(mysql_error());$num = mysql_num_rows($fet1);if(!$page){$page = 1;};if($news == 0){echo "news not enabled";}else {if($num == 0){echo "No news";}else {while ($fet2 = mysql_fetch_array($fet1, MYSQL_BOTH)){if(!$camount){$camount = 0;};echo "<table border=0 cellspacing=2 cellpadding=2><tr><td colspan=2 align=right><h3>$fet2[title]</h3><tr><td colspan=2 align=left>Posted on: $fet2[date] at $fet2[time] by $fet2[poster]<tr><td colspan=2 align=left>$fet2[body]<tr><td align=left>Category: $fet2[category]<td align=right>";if($fet2[comments] == 1){echo "<a href=comments.php?id=$fet2[id]>$fet2[camount] Comments</a></table><br><br>";};mysql_free_result($fet1);};};};?><? require('footer.php'); ?>[/code] Quote Link to comment Share on other sites More sharing options...
Stooney Posted November 25, 2006 Share Posted November 25, 2006 well the query may not be going throughtry [code]if($fet1){ while ($fet2 = mysql_fetch_array($fet1, MYSQL_BOTH)){ if(!$camount) $camount = 0; }}else echo "query failed";[/code] Quote Link to comment Share on other sites More sharing options...
marcus Posted November 25, 2006 Author Share Posted November 25, 2006 yep, that's exactly what i did, thanks anyway Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.