scarhand Posted July 15, 2007 Share Posted July 15, 2007 I am getting this error and can't understand why. This is in regards to attempting to retreive data from PHPBB tables so that I can display 5 posts as news articles on my main home page. Here is my code: <?php include 'forumconfig.php'; $query = 'SELECT t.topic_id, t.topic_title, pt.post_text, u.username, u.user_id, t.topic_replies, t.forum_id, t.topic_poster, t.topic_first_post_id, t.topic_status, pt.post_id, p.post_id, FROM phpbb_topics AS t, phpbb_users AS u, phpbb_posts_text AS pt, phpbb_posts AS p WHERE t.forum_id IN (1) AND t.topic_poster = u.user_id AND t.topic_first_post_id = pt.post_id AND t.topic_first_post_id = p.post_id AND t.topic_status <> 2 ORDER BY t.topic_time DESC LIMIT 5'; $result = mysql_query($query); if (mysql_num_rows($result) == 0) { echo 'There is currently no news to display.'; } while ($row = mysql_fetch_assoc($result)) { $title = $row['t.topic_title']; $news = $row['pt.post_text']; $poster = $row['u.username']; $topicid = $row['t.topic_id']; $comments = $row['t.topic_replies']; echo '<div class="headns">' . $title . '</div><br />'; echo $news . '<br /><br />'; echo '- ' . $poster . '<br />'; echo '<a href="forums/viewtopic.php?t=' . $topicid . '">comments (' . $comments . ')</a><br /><br />'; }?> Now the 'forumconfig.php' file just connects to the database for the phpbb forum, that works fine. For some reason I am getting "mysql_num_rows(): supplied argument is not a valid MySQL result resource", as well as "mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource". I can't seem to figure out why. Any help would be greatly appreciated. Quote Link to comment Share on other sites More sharing options...
trq Posted July 15, 2007 Share Posted July 15, 2007 $result = mysql_query($query) or die(mysql_error()."<br />$query"); Quote Link to comment Share on other sites More sharing options...
scarhand Posted July 15, 2007 Author Share Posted July 15, 2007 $result = mysql_query($query) or die(mysql_error()."<br />$query"); Thanks. Figured out I just had to remove 1 comma. 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.