PHP Code:
<?php
include "includes/config.php";
echo "<div>";
$con = mysql_connect($config['MasterServer']['servername'], $config['MasterServer']['username'], $config['MasterServer']['password']) or die(mysql_error());
mysql_select_db($config['Database']['dbname'], $con) or die(mysql_error());
$selectthread = mysql_query("SELECT * FROM `thread` WHERE `forumid`='171' ORDER BY RAND() LIMIT 0,1") or die(mysql_error());
$address = "http://www.akvaryumforum.com/forum";
while ($row=mysql_fetch_array($selectthread)) {
$attc = $row['firstpostid'] ;
$selectattachment = mysql_query("SELECT * FROM `attachment` WHERE `contentid`='{$attc}'");
while ($att=mysql_fetch_array($selectattachment)) {
echo "<tr><td><img src='{$address}/attachment.php?attachmentid={$att['attachmentid']}&stc=1&thumb=1&d=1262998375' /><br /><a href=\"{$address}/showthread.php?t={$row['threadid']}\" target=\"_self\">{$row['title']}</a>";
}
}
echo "</div>";
?>
I use this code to show random thread and the attachment image in the first post of thread. It work fine in a seperate php file. But when i use this code in the Widget it shows the content over the header, when i try to use it in a Forum Block Forumhome says no database selected and don't show anything else.
How can i do this script work?