MoFish Posted December 18, 2006 Share Posted December 18, 2006 hello everyone. i'm trying to display the contents of a database in a separate table for each, however am running into a bit of trouble. it currently displays the first row of data fine in its table but doesn't display the second. here is the error i get.[color=red]Warning: mysql_fetch_assoc(): 4 is not a valid MySQL result resource in D:\web-server\www\Abertay\displaynews.php on line 29[/color][code]$query_SelectNews = "SELECT * FROM newstable ORDER BY news_id ASC";$SelectNews = mysql_query($query_SelectNews, $ConnectAbertay) or die(mysql_error());$row_SelectNews = mysql_fetch_assoc($SelectNews);$totalRows_SelectNews = mysql_num_rows($SelectNews);?><title>DisplayNews</title><?phpmysql_free_result($SelectNews);?><?php do { ?><table width="400px" border="1" cellspacing="2" cellpadding="2"> <tr> <td><?php echo $row_SelectNews['news_title']; ?></td> <td><?php echo $row_SelectNews['news_date']; ?></td> </tr> <tr> <td><?php echo $row_SelectNews['news_image']; ?></td> <td><?php echo $row_SelectNews['news_message']; ?></td> </tr> <tr> <td colspan="2"><?php echo $row_SelectNews['news_postedby']; ?></td> </tr></table><?php } while ($row_SelectNews = mysql_fetch_assoc($SelectNews)); ?>[/code] Link to comment https://forums.phpfreaks.com/topic/31038-solved-displaying-data-from-mysql/ Share on other sites More sharing options...
trq Posted December 18, 2006 Share Posted December 18, 2006 Remove...[code=php:0]mysql_free_result($SelectNews);[/code] Link to comment https://forums.phpfreaks.com/topic/31038-solved-displaying-data-from-mysql/#findComment-143270 Share on other sites More sharing options...
MoFish Posted December 18, 2006 Author Share Posted December 18, 2006 magic, thank you. lol Link to comment https://forums.phpfreaks.com/topic/31038-solved-displaying-data-from-mysql/#findComment-143278 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.