ChrisLawrie Posted December 2, 2003 Share Posted December 2, 2003 Hi all i need help! I am trying to create a table of 10 latest posts from my forums on the first page of my site. I have tried the following code but errors occur: <h1>LAST 10 POSTS</h1> <table border=\"1\"> <tr> <td class=\"white\"><strong>Topic ID</strong></td> <td class=\"white\"><strong>Topic Title</strong></td> <td class=\"white\"><strong>Topic Time</strong></td> <td class=\"white\"><strong>Topic Views</strong></td> <td class=\"white\"><strong>Forum ID</strong></td> <td class=\"white\"><strong>Forum Name</strong></td> <td class=\"white\"><strong>User Name</strong></td> </tr> <?php mysql_pconnect(\"localhost\",\"***\",\"***\"); $query=\"SELECT topic_id, topic_title, topic_time, topic_views, t.forum_id, f.forum_name, u.uname FROM \".$mpnTables.\" t, \".$mpnTables.\" f, \".$mpnTables.\" u where (f.forum_id=t.forum_id) and (forum_type \'1\') and (t.last_post=u.uid) ORDER BY topic_time desc LIMIT 10\"; $result=mysql_db_query(\"***\",$query); while($row=mysql_fetch_row($result)){ ?> <tr> <td class=\"white\"><?php print($row[0]);?></td> <td class=\"white\"><?php print($row[1]);?></td> <td class=\"white\"><?php print($row[2]);?></td> <td class=\"white\"><?php print($row[3]);?></td> <td class=\"white\"><?php print($row[4]);?></td> <td class=\"white\"><?php print($row[5]);?></td> <td class=\"white\"><?php print($row[6]);?></td> </tr> <?php } mysql_free_result($result); ?> </table> Gives following errors: Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in ***/index2.php on line 170 Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in ***/index2.php on line 183 Any suggestions anyone? My tables are called: mpn_topics, mpn_forums,mpn_users. Cheers Quote Link to comment https://forums.phpfreaks.com/topic/1448-help-creating-a-table/ Share on other sites More sharing options...
shivabharat Posted December 2, 2003 Share Posted December 2, 2003 The porblem is in the query Try this $result=mysql_db_query("***",$query) or die(mysql_error()); You will get an idea what the error is. Quote Link to comment https://forums.phpfreaks.com/topic/1448-help-creating-a-table/#findComment-4788 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.