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] Link to comment https://forums.phpfreaks.com/topic/28384-mysql-help-needed-solved/ 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] Link to comment https://forums.phpfreaks.com/topic/28384-mysql-help-needed-solved/#findComment-129919 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 Link to comment https://forums.phpfreaks.com/topic/28384-mysql-help-needed-solved/#findComment-129920 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.