Current time: 07-25-2014, 11:18 AM Hello There, Guest! (LoginRegister)


Post Reply 
 
Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Displaying News on Homepage
09-25-2005, 01:05 AM
Post: #1
Displaying News on Homepage
I want to use my own homepage, and put news from MyBB on it. Anyone wanna help?

Here is the page

http://www.techtabs.com/index.php

(I have tried and failed Sad)

Xbox 360 Forum
Visit this user's website Find all posts by this user
Quote this message in a reply
09-25-2005, 05:24 AM (This post was last modified: 09-25-2005 05:42 AM by k776.)
Post: #2
RE: Displaying News on Homepage
Try:
PHP Code:
<?php
$mysqlusername 
"";
$mysqlpassword "";
$mysqldbselect "";
$prefix "mybb_";
$fid "2";

mysql_select_db($mysqldbselectmysql_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&amp;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 Big Grin)
Visit this user's website Find all posts by this user
Quote this message in a reply
09-25-2005, 01:20 PM
Post: #3
RE: Displaying News on Homepage
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.
Find all posts by this user
Quote this message in a reply
09-25-2005, 09:44 PM
Post: #4
RE: Displaying News on Homepage
Yea I got the same errors.

Xbox 360 Forum
Visit this user's website Find all posts by this user
Quote this message in a reply
09-26-2005, 01:04 AM
Post: #5
RE: Displaying News on Homepage
Try this:
Code:
<?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&amp;uid=".$news['uid']."\">".$news['username']."</a> | Replies: <a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['replies']."</a><hr />".$news['message']."<br /><br />";
}
?>

Dennis Tsang
http://dennistt.net
Find all posts by this user
Quote this message in a reply
09-26-2005, 02:13 AM
Post: #6
RE: Displaying News on Homepage
Odd still dosen't work even after modfcations. Any other ideas?

Xbox 360 Forum
Visit this user's website Find all posts by this user
Quote this message in a reply
09-26-2005, 02:24 AM (This post was last modified: 09-26-2005 02:27 AM by k776.)
Post: #7
RE: Displaying News on Homepage
Hmm. Run this (after chaning the 6 values to the correct details) and tell me the output.
PHP Code:
<?php
$mysqlhost 
"localhost";
$mysqlusername "";
$mysqlpassword "";
$mysqldbselect "";
$prefix "mybb_";
$fid "2";

mysql_select_db($mysqldbselectmysql_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&amp;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.
Visit this user's website Find all posts by this user
Quote this message in a reply
09-26-2005, 09:51 AM
Post: #8
RE: Displaying News on Homepage
k776 Wrote:Hmm. Run this (after chaning the 6 values to the correct details) and tell me the output.
PHP Code:
<?php
$mysqlhost 
"localhost";
$mysqlusername "";
$mysqlpassword "";
$mysqldbselect "";
$prefix "mybb_";
$fid "2";

mysql_select_db($mysqldbselectmysql_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&amp;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.
Causes:
Quote:Column: 'fid' in where clause is ambiguous

NetAdmin @ PharosIRC
irc.pharosirc.net
#Help,#lobby,#linux
MrStatic
Visit this user's website Find all posts by this user
Quote this message in a reply
09-26-2005, 07:25 PM
Post: #9
RE: Displaying News on Homepage
Yea thats what I get to any ideas?

Xbox 360 Forum
Visit this user's website Find all posts by this user
Quote this message in a reply
09-26-2005, 07:49 PM
Post: #10
RE: Displaying News on Homepage
Alright Confused Try this
PHP Code:
<?php
$mysqlhost 
"localhost";
$mysqlusername "";
$mysqlpassword "";
$mysqldbselect "";
$prefix "mybb_";
$fid "2";

mysql_select_db($mysqldbselectmysql_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&amp;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 Code:
<?php
$mysqlhost 
"localhost";
$mysqlusername "";
$mysqlpassword "";
$mysqldbselect "";
$prefix "mybb_";

mysql_select_db($mysqldbselectmysql_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&amp;uid=".$news['uid']."\">".$news['username']."</a> | Replies: <a href=\"./forum/showthread.php?tid=".$news['tid']."\">".$news['replies']."</a><hr />".$news['message']."<br /><br />";
}
?>
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)

Contact Us | MyBB | Return to Top | Return to Content | Lite (Archive) Mode | RSS Syndication