phpBB2 Last 5 Topics

By F*U*R*B*Y* on Dec 05, 2008

Basically, this is http://www.hawkee.com/snippet/5344/ but written for phpBB2 :)

Hopefully everyone can use this.

<?php

    echo "<b>5 Latest Posts on the Discussion Forums.</b><br />";

    // How Many Topics you want to display?
    $topicnumber = 5;
    // Change this to your phpBB path
    $urlPath = "/phpbb";
    // Database Configuration (Where your phpBB config.php file is located)
    include $urlPath.'/config.php';

    $link = mysql_connect($dbhost, $dbuser, $dbpasswd) or die("Could not connect");
    mysql_select_db($dbname) or die("Could not select database");

    // Get 5 Latest Posts.
    $qry = mysql_query("SELECT * FROM `posts` ORDER BY `post_id` DESC LIMIT 5");
    while($row=mysql_fetch_array($qry)) {

        // Get Author Name.
        $author1 = mysql_query("SELECT * FROM `users` WHERE `user_id` = '".$row['poster_id']."'");
        $author2 = mysql_fetch_array($author1);
        $author = $author2['username'];

        // Get the Forum Name
        $forum1 = mysql_query("SELECT * FROM `forums` WHERE `forum_id` = '".$row['forum_id']."'");
        $forum2 = mysql_fetch_array($forum1);
        $forum = $forum2['forum_name'];

        // Get the Topic Name.
        $topic1 = mysql_query("SELECT * FROM `topics` WHERE `topic_id` = '".$row['topic_id']."'");
        $topic2 = mysql_fetch_array($topic1);
        $topic = $topic2['topic_title'];

        printf("<b><a href=\"".$urlPath."/viewforum.php?f=%s\" target=\"_BLANK\">%s</a></b> -> <b><a href=\"".$urlPath."/viewtopic.php?f=%s&t=%s&p=%s#%s\" target=\"_BLANK\">%s</a></b> by <a href=\"".$urlPath."/profile.php?mode=viewprofile&u=%s\" TARGET=\"_blank\">%s</a><br />", $row['forum_id'], $forum, $row['forum_id'], $row['topic_id'], $row['post_id'], $row['post_id'], $topic, $row['poster_id'], $author);

    }

    mysql_free_result($row);
    mysql_close($link);

?>
Sign in to comment.
Xpl0reR   -  Nov 14, 2009

i am looking for a script to put in your mIRC and to get notificaions if there is a new post on a PHPBB3 forum.. Got any idea? the forum in question is forum.undernet.org

 Respond  
hawkeeuser   -  May 07, 2009

LordHawk its not like this the script need lil change but i fix it for me no need for these lines $urlPath = "/phpbb";

// Database Configuration (Where your phpBB config.php file is located)
include $urlPath.'/config.php';

if the below line is something like this

$link = mysql_connect($dbhost = '', $dbuser = 'yourdb user', $dbpasswd = 'your dbpass') or die("Could not connect");
mysql_select_db($dbname = 'your dbname') or die("Could not select database");

and you don't need this as well mysql_free_result($row);

mysql_close($link);
 Respond  
Hawkee   -  May 07, 2009

Looks like this needs the include statements required to use the phpBB2 libraries. These can be found at the top of any of the phpBB2 front end php scripts such as viewforum.php

 Respond  
LordHawk   -  May 07, 2009

Hawkeeuser, it uses the config.php already in phpbb. If your config file is properly set then it will work fine.

 Respond  
hawkeeuser   -  May 06, 2009

Furby do we need to give db name userid or pass in line $link = mysql_connect($dbhost, $dbuser, $dbpasswd) because im getting error i only use a path /phpBB2

 Respond  
LordHawk   -  Feb 22, 2009

Very nicely done Furby.

 Respond  
essami   -  Jan 27, 2009

yes! that seems to have done the trick, now it says

5 Latest Posts on the Discussion Forums.

Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/fonal/fonal.com/newstest.php on line 133

Warning: mysql_free_result(): supplied argument is not a valid MySQL result resource in /home/fonal/fonal.com/newstest.php on line 154

 Respond  
F*U*R*B*Y*   -  Jan 26, 2009

try having ./forum

instead of /forum shrugs

no idea, just a suggestion

 Respond  
essami   -  Jan 26, 2009

Hi,

Id like to use this on my website but Im a total novice on this. If anyone has the patience to walk me through Id appreaciate it :)

My forum is here: www.fonal.com/forum

and Im trying to add the 5 newest posts on this page (a testpage): http://www.fonal.com/newstest.php

scroll down to see the problem, thanks!

 Respond  
NIGathan   -  Dec 11, 2008

Heh, if I used php, I would rate/like, but its of no use to me

 Respond  
F*U*R*B*Y*   -  Dec 11, 2008

no score and no likes :(

 Respond  
NIGathan   -  Dec 10, 2008

http://www.hawkee.com/snippet/5420/

You sir, won a golden ticket. /me loads a bowl in celebration

 Respond  
F*U*R*B*Y*   -  Dec 10, 2008

^_^ Nothing... I don't use it so I don't create scripts for it...

Any real comments/scores/likes for this script is welcomed....

 Respond  
IuClik   -  Dec 08, 2008

For Invision Power Board you have?

 Respond  
F*U*R*B*Y*   -  Dec 06, 2008

no comments? no scores? no likes?

no nothing? :(

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.