Forum Moderators: coopster
$absolutPath = "/absolut/path/to/config.php";
$urlPath = "http://www.domain.de/folder";
$limit = "10";
include_once("$absolutPath");
$db = @mysql_connect("$dbhost", "$dbuser", "$dbpasswd") or die("Problem!?");
@mysql_select_db("$dbname",$db) or die("No available?");
$sql = "SELECT t.topic_title, t.topic_time, u.username, t.topic_id, f.forum_id
FROM topics t, forums f, users u WHERE t.topic_poster = u.user_id AND f.forum_id = t.forum_id AND f.forum_type!= '1'
ORDER BY topic_time DESC LIMIT $limit";
if ($r = mysql_query($sql, $db)) {
echo "<table width=\"50%\">";
echo "<tr><td><b>Recent Topics:</b></td></tr>";
while($m = mysql_fetch_array($r)) {
$j = stripslashes($m[topic_title]);
if ($shortsubj) $k = substr($j, 0, 20) . "..."; else $k = $j;
echo "<tr><td><a href=\"$urlPath/viewtopic.php?topic=$m[topic_id]&forum=$m[forum_id]\">$k</a></td>";
echo "<td> ( ".$m["topic_time"]." )</td>";
echo "<td> by ".$m["username"]."</td></tr>";
}
echo "</table>";
}
?>
obviously you have to connect to the mysql db where phpbb is running. so $dbhost is something like domain-with-phpbb-running.com.
you also have to open up the mysql db. you have to allow connections from outside.
if this is not set up yet, there are 2 things you should check.
1. my.cnf (mysql config file)
in the my.cnf the following lines should open up the connection from outside:
port = 3306
#skip-networking (the # is there on purpose)
2. permissions of the db user.
the user you want to use to connect with the mysql db has to have the right host set up. (user table in the mysql db)
hope this helps
barn
Thanks for your help.
Another question- Do I get rid of the $absolutpath variable all together? From the error message I"m getting, it looks like PHP is looking for the include file on the server that is displaying the posts (not the server that is hosting the forum).
Error:
Warning: main(/forumtemp/webroot/htdocs/config.php): failed to open stream: No such file or directory in /home/website/www/services/test.php on line 63
Thanks.
What I did was to create a page on the site that was running the forum and the database from which I wanted to pull the posts. That page pulls and displays the 10 most recent posts. Then on my other site I just did an include of this page. Much easier than trying to connect to an external database.