Try:
<?php
$mysqlusername = "";
$mysqlpassword = "";
$mysqldbselect = "";
$prefix = "mybb_";
$fid = "2";
mysql_select_db($mysqldbselect, mysql_connect("localhost",$mysqlusername,$mysqlpassword));
$query = mysql_query("SELECT t.tid,t.subject,t.uid,t.username,t.replies,p.message FROM ".$prefix."threads t LEFT JOIN ".$prefix."posts p ON (t.tid = p.tid) WHERE fid='".$fid."' AND visible='1' AND closed NOT LIKE 'moved|%'");
while($news = mysql_fetch_array($query))
{
echo "<a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['subject']."</a> | Posted by: <a href=\"./forum/member.php?action=profile&uid=".$news['uid']."\">".$news['username']."</a> | Replies: <a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['replies']."</a><hr />".$news['message']."<br /><br />";
}
?>
Change the 5 values at the top to suit you forums configuration. First three are you database name, database username, and database password to your mySQL server. The next is the table prefix. If you gave your forum a different prefix, change it so it works. Lastly, add the forum id you want to pull the announcements/news from.
That should work. I havn't tested it though.
Edit: That code above will output something similar:
Quote:Forum is now open | Posted by: Admin | Replies: 34
Welcome to the forum. I trust you will enjoy it. I'm running MyBB. You can find it at http://www.mybboard.com/. Its very professional and I will continue to keep up to date with it as it is free. If you have a server, I encourage you to try it out.
(details will change depending on the post and auther of coarse
)
k776, I was also looking for a way to do that. I changed the variables, but I get this error.
Quote:Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/x/s/xs/public_html/test/index.php on line 135
Any idea why? It seems to me that it can't do the query for some reason.
Yea I got the same errors.
Try this:
<?php
$mysqlhost = "localhost";
$mysqlusername = "";
$mysqlpassword = "";
$mysqldbselect = "";
$prefix = "mybb_";
$fid = "2";
mysql_connect($mysqlhost,$mysqlusername,$mysqlpassword);
mysql_select_db($mysqldbselect);
$query = mysql_query("SELECT t.tid,t.subject,t.uid,t.username,t.replies,p.message FROM ".$prefix."threads t LEFT JOIN ".$prefix."posts p ON (t.tid = p.tid) WHERE fid='".$fid."' AND visible='1' AND closed NOT LIKE 'moved|%'");
while($news = mysql_fetch_array($query))
{
echo "<a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['subject']."</a> | Posted by: <a href=\"./forum/member.php?action=profile&uid=".$news['uid']."\">".$news['username']."</a> | Replies: <a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['replies']."</a><hr />".$news['message']."<br /><br />";
}
?>
Odd still dosen't work even after modfcations. Any other ideas?
Hmm. Run this (after chaning the 6 values to the correct details) and tell me the output.
<?php
$mysqlhost = "localhost";
$mysqlusername = "";
$mysqlpassword = "";
$mysqldbselect = "";
$prefix = "mybb_";
$fid = "2";
mysql_select_db($mysqldbselect, mysql_connect($mysqlhost,$mysqlusername,$mysqlpassword));
$query = mysql_query("SELECT t.tid,t.subject,t.uid,t.username,t.replies,p.message FROM ".$prefix."threads t LEFT JOIN ".$prefix."posts p ON (t.tid = p.tid) WHERE fid='".$fid."' AND visible='1' AND closed NOT LIKE 'moved|%'") or die(mysql_error());
while($news = mysql_fetch_array($query))
{
echo "<a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['subject']."</a> | Posted by: <a href=\"./forum/member.php?action=profile&uid=".$news['uid']."\">".$news['username']."</a> | Replies: <a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['replies']."</a><hr />".$news['message']."<br /><br />";
}
?>
There doesn't actually seem to be anything wrong with it so I'm not sure why its not working.
Yea thats what I get to any ideas?
Alright
Try this
<?php
$mysqlhost = "localhost";
$mysqlusername = "";
$mysqlpassword = "";
$mysqldbselect = "";
$prefix = "mybb_";
$fid = "2";
mysql_select_db($mysqldbselect, mysql_connect($mysqlhost,$mysqlusername,$mysqlpassword));
$query = mysql_query("SELECT t.tid,t.subject,t.uid,t.username,t.replies,p.message FROM ".$prefix."threads t LEFT JOIN ".$prefix."posts p ON (t.tid = p.tid) WHERE fid=$fid AND visible='1' AND closed NOT LIKE 'moved|%'") or die(mysql_error());
while($news = mysql_fetch_array($query))
{
echo "<a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['subject']."</a> | Posted by: <a href=\"./forum/member.php?action=profile&uid=".$news['uid']."\">".$news['username']."</a> | Replies: <a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['replies']."</a><hr />".$news['message']."<br /><br />";
}
?>
or if that doesn't work
<?php
$mysqlhost = "localhost";
$mysqlusername = "";
$mysqlpassword = "";
$mysqldbselect = "";
$prefix = "mybb_";
mysql_select_db($mysqldbselect, mysql_connect($mysqlhost,$mysqlusername,$mysqlpassword));
$query = mysql_query("SELECT t.tid,t.subject,t.uid,t.username,t.replies,p.message FROM ".$prefix."threads t LEFT JOIN ".$prefix."posts p ON (t.tid = p.tid) WHERE fid='2' AND visible='1' AND closed NOT LIKE 'moved|%'") or die(mysql_error());
while($news = mysql_fetch_array($query))
{
echo "<a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['subject']."</a> | Posted by: <a href=\"./forum/member.php?action=profile&uid=".$news['uid']."\">".$news['username']."</a> | Replies: <a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['replies']."</a><hr />".$news['message']."<br /><br />";
}
?>