Hi, Ive searched around but haven't had any luck, Basically what im trying to do with phpbb version 2.0.22 is to show the last 5 or so active or recent forum topics on my mainpage of my webpage.. I found this code but its given me error when I load it. Maybe someone can lend a helping hand real quick on this.. Thank guys! <? /** * Mod Title: Latest Topics * Mod Version: phpBB 2.0.4 * Author: Charlie Page * Description: Shows latest topics on any page * Release: v1.0, 05.30.2004 *** * Demo: http://www.xboxassassin.com/e3 * Installation Level: Easy * Installation Time: 1 minute * Files To Edit: This one * Included Files: php-latest.php *** * Installation Notes: * Upload this file and set $ppath and $url, * Include this into a page and your done! */ $url = "/forums"; // If url is - http://www.yourforums.com/forums , then enter in "/forums" $ppath = "/home/MYSITE/public_html/MYSITEAGAIN/forums/config.php"; // Physical path to the config.php file if(empty($count)) $count = "5"; // How many topics to link to //-----------------[ DO NOT EDIT BELOW HERE ]------------------------- include_once("$ppath"); $db = @mysql_connect("$dbhost", "$dbuser", "$dbpasswd") or die("here we die at connection"); @mysql_select_db("$dbname",$db) or die("here we die"); $prefix = "$table_prefix"; $query="SELECT * FROM $prefix_topics ORDER BY `topic_id` DESC LIMIT 0, $count"; $result=mysql_query($query); while($row = mysql_fetch_array($result)) { $topicid = "$row[topic_id]"; $title = "$row[topic_title]"; $forumid = "$row[forum_id]"; $replies = "$row[topic_replies]"; echo "- <a title=\"$title\" href=\"$url/viewtopic.php?t=$topicid&sid=$forumid\">$title</a> (<i>$replies</i>)<br>"; } ?> PHP: this is the error im getting Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/MYSITE/public_html/MYSITEAGAIN/phpbb-latest.php on line 33 HTML:
I realize this is a bit of thread necromancy, but I found this thread through a search engine while I was having the same problem, so I post the solution here for the sake of posterity. The problem is it's trying to select from a table name stored in a string called "$prefix_topics". As you notice, that string hasn't been defined, so it's a blank string, and the query returns nothing, because no valid table was selected. Change that line to: $query="SELECT * FROM `" . $prefix . "topics` ORDER BY `topic_id` DESC LIMIT 0, $count"; PHP: and it'll work perfectly. This is the code to fulfill the author's original intent - to use the $prefix string from config.php, and tack 'topics' on the end, so the selected table is "yourphpprefix_topics".