Page 1 of 1

phpbb topics in geeklog block

Posted: Sat Dec 26, 2009 7:01 am
by Stevyn
source: http://www.geeklog.net/article.php/2002 ... uery=phpbb

Code: Select all

function phpblock_phpbb2recent() {

// You MUST copy the following 4 variables from your config.php file in your phpbb2 install
$dhhost = "localhost";
$dbname = "phpBB";
$dbuser = "name";
$dbpasswd = "pass";

$urlPath = "http://yoursitehere/phpBB2";
$PostNumber = "5";
$type = "posts";
$length = "12";

$db = @mysql_connect($dbhost, $dbuser, $dbpasswd);

@mysql_select_db($dbname,$db);
if ($db == "") {
die("Failed to connect to server! YOUR SCREWED!!");
}

// Get data
if($type == "posts") {
$sql = "SELECT * FROM phpbb_topics ORDER BY topic_time DESC LIMIT 5;"; //note phpbb_topics in this case worked for me seeing as how thats where the correct tables were...you will have to find and change this as necessary for it to work for you.

} else {
$sql = "SELECT * FROM phpbb_topics ORDER BY topic_time DESC LIMIT 5;";
}
$r = mysql_query($sql, $db);

if ($r == FALSE) {
die("Unable to get data!");
}

// Display data
$rows = mysql_num_rows($r);


for ($row_number = 0; $row_number <= $rows - 1; $row_number++) {
$topic_title = mysql_result($r, $row_number, "topic_title");
$topic_title = stripslashes($topic_title);
$k = substr($topic_title, 0, $length) . "...";
$topic_id = mysql_result($r, $row_number, "topic_id");

$forum_id = mysql_result($r, $row_number, "forum_id");

$recent .= "<li><a title='" . $topic_title . "' class='forum' href='" . $urlPath . "/viewtopic.php?t=" . $topic_id . "&sid=" . $forum_id . "'>$k</a></li>";

}

return $recent;

}






Authored by: Kybla on Thursday, July 11 2002 @ 08:40 AM EDT
There should be \"dbhost\" instead of \"dhhost\" in the first line under \"// You MUST copy....blahblah\" .. just for those who couldn\'t realize why it doesn\'t work :)