hlstriker Posted August 15, 2006 Share Posted August 15, 2006 Hey, I am trying to make a forum in PHPBB called News, display all the news in it's forum, on a custom news page on my main website. I have most of it written already, but some reson it doesn't display the poster name, and it puts all the post_text (the news itself) into the same table as the first news displayed.Here is the code if anyone can tell me what to fix.[code]<? mysql_connect("host","user","pass"); mysql_select_db("db"); // Get the topics info and posts info $querytopics = "SELECT topic_id, forum_id, topic_title, topic_poster, topic_replies FROM phpbb_topics"; $queryposts = "SELECT post_text FROM phpbb_posts_text"; $queryusers = "SELECT user_id, username FROM phpbb_users"; //Query the above... $resulttopics = mysql_query($querytopics) or die('Error, query failed'); $resultposts = mysql_query($queryposts) or die('Error, query failed'); $resultusers = mysql_query($queryusers) or die('Error, query failed'); if((mysql_num_rows($resulttopics) == 0)) { echo "News database is empty <br />"; } else { while(list($topic_id, $forum_id, $topic_title, $topic_poster, $topic_replies) = mysql_fetch_array($resulttopics)) { ?> <table border="1" cellspacing="0" cellpadding="3" align='center' width='100%' bgcolor='#000000'> <tr> <td colspan='2' align='left'><? echo $topic_title; ?></td> </tr> <tr> <td colspan='2' align='left' valign='top'> <? while(list($post_text) = mysql_fetch_array($resultposts)) { echo $post_text; } ?> </td> </tr> <tr> <td align='left'><? echo $topic_replies; ?> replies</td> <td align='right'>Posted by <? while(list($user_id, $username) = mysql_fetch_array($resultusers)) { while(!$user_id == $topic_poster) { if($user_id == $topic_poster) { echo $username; } } } ?> </td> </tr> </table> <br><br> <? } } mysql_close;?>[/code]If anyone could help me please do! Thanks! Quote Link to comment Share on other sites More sharing options...
hlstriker Posted August 16, 2006 Author Share Posted August 16, 2006 Just wondering if anyone could help me, I really need to get this fixed :o Quote Link to comment Share on other sites More sharing options...
fccid Posted August 16, 2006 Share Posted August 16, 2006 first of all, why dont you just define the page as being in phpbb, to remove the hassle and the security problems you might encounter doing it that way..usually this code on the very top:[code]define('IN_PHPBB', true);$phpbb_root_path = 'forum/';include($phpbb_root_path . 'extension.inc');include($phpbb_root_path . 'common.'.$phpEx);include($phpbb_root_path . 'fetchposts.'.$phpEx);//// Start session management//$userdata = session_pagestart($user_ip, PAGE_INDEX);init_userprefs($userdata);//// End session management//[/code]that way, you dont have to manually do another query... here's the code to fetch the announcements, again you can define and customize it as you wish.. you can also output it in its own custom template, which declutters your code:[code]//// Fetch Posts from Announcements Forum//if(!isset($HTTP_GET_VARS['article'])){ $template->assign_block_vars('welcome_text', array()); $fetchposts = phpbb_fetch_posts($CFG['news_forum'], $CFG['number_of_news'], $CFG['news_length']); for ($i = 0; $i < count($fetchposts); $i++) { if( $fetchposts[$i]['striped'] == 1 ) { $open_bracket = '[ '; $close_bracket = ' ]'; $read_full = $lang['Read_Full']; } else { $open_bracket = ''; $close_bracket = ''; $read_full = ''; } $template->assign_block_vars('fetchpost_row', array( 'TITLE' => $fetchposts[$i]['topic_title'], 'POSTER' => $fetchposts[$i]['username'], 'TIME' => $fetchposts[$i]['topic_time'], 'TEXT' => $fetchposts[$i]['post_text'], 'REPLIES' => $fetchposts[$i]['topic_replies'], 'U_VIEW_COMMENTS' => append_sid('viewtopic.' . $phpEx . '?t=' . $fetchposts[$i]['topic_id']), 'U_POST_COMMENT' => append_sid('posting.' . $phpEx . '?mode=reply&t=' . $fetchposts[$i]['topic_id']), 'U_READ_FULL' => append_sid('portal.' . $phpEx . '?article=' . $i), 'L_READ_FULL' => $read_full, 'OPEN' => $open_bracket, 'CLOSE' => $close_bracket) ); }}else{ $fetchposts = phpbb_fetch_posts($CFG['news_forum'], $CFG['number_of_news'], 0); $i = intval($HTTP_GET_VARS['article']); $template->assign_block_vars('fetchpost_row', array( 'TITLE' => $fetchposts[$i]['topic_title'], 'POSTER' => $fetchposts[$i]['username'], 'TIME' => $fetchposts[$i]['topic_time'], 'TEXT' => $fetchposts[$i]['post_text'], 'REPLIES' => $fetchposts[$i]['topic_replies'], 'U_VIEW_COMMENTS' => append_sid('viewtopic.' . $phpEx . '?t=' . $fetchposts[$i]['topic_id']), 'U_POST_COMMENT' => append_sid('posting.' . $phpEx . '?mode=reply&t=' . $fetchposts[$i]['topic_id']) ) );}//// END: Fetch Announcements//[/code]original code by (c) smartor_xp@hotmail.com Quote Link to comment Share on other sites More sharing options...
hackerkts Posted August 16, 2006 Share Posted August 16, 2006 Hmm.. Shouldn't this be in 3rd party script ? Quote Link to comment Share on other sites More sharing options...
hlstriker Posted August 16, 2006 Author Share Posted August 16, 2006 Hi fccid, thanks for posting, but i'm getting warnings on the page. Here is what I get...[quote]Warning: include(forum/fetchposts.php) [function.include]: failed to open stream: No such file or directory in /(dirs)/news.php on line 8Warning: include() [function.include]: Failed opening 'forum/fetchposts.php' for inclusion (include_path='.:/usr/local/php5/lib/php') in /(dirs)/news.php on line 8Warning: Cannot modify header information - headers already sent by (output started at /(dirs)/news.php:8 ) in (dirs)/forum/includes/sessions.php on line 254Warning: Cannot modify header information - headers already sent by (output started at /(dirs)/news.php:8 ) in (dirs)/forum/includes/sessions.php on line 255Fatal error: Call to undefined function: phpbb_fetch_posts() in /(dirs)/news.php on line 26[/quote]Thanks. Quote Link to comment Share on other sites More sharing options...
hackerkts Posted August 19, 2006 Share Posted August 19, 2006 Check where you put your fetchposts.php 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.