Jeffrey
01-29-2001, 01:14 AM
On my main page ( www.caviesgalore.com ) I get:
Warning: Cannot add header information - headers already sent by (output started at /home2/cavy4me/public_html/index.php:7) in /home2/cavy4me/public_html/forums/global.php on line 1495
Warning: Cannot add header information - headers already sent by (output started at /home2/cavy4me/public_html/index.php:7) in /home2/cavy4me/public_html/forums/global.php on line 1501
When I try to display the last 4 posts. The code I'm using is, what can I do?:
<?
chdir("/home/cavy4me/public_html/forums/");
include("global.php");
$num_active = 4;
$num_chars = 40;
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$querylatest="SELECT * FROM thread WHERE forumid='1' OR forumid='2' OR forumid='3' OR forumid='4' OR forumid='5' OR forumid='6' OR forumid='10' ORDER BY lastpost DESC LIMIT $num_active";
$resultlatest = mysql_query($querylatest,$db);
while ($latest_array = mysql_fetch_array($resultlatest)) {
// Get Forum Infomation
$query_forum = "select * from forum where forumid='$latest_array[forumid]'";
$result_forum = mysql_query($query_forum,$db);
$forum_info_array = mysql_fetch_array($result_forum);
// split the date up a bit
$datestr1 = substr($latest_array["dateline"],0,10);
$datetime = substr($latest_array["dateline"],11,8);
$querythread="SELECT * FROM post WHERE threadid='$latest_array[threadid]' ORDER BY dateline ASC LIMIT 1";
$result_thread_text= mysql_query($querythread,$db);
$result_thread_array = mysql_fetch_array($result_thread_text);
$newstitle = $latest_array["title"];
$newsposter = $latest_array["postusername"];
$newsposterid = $result_thread_array["userid"];
$newsdate = date("D j M Y", $latest_array["dateline"]);
$newstext = substr(strip_tags($result_thread_array["pagetext"]),0,$num_chars);
$newsthreadid = $latest_array["threadid"];
$newscomments = $latest_array["replycount"];
$threadforumid = $latest_array["forumid"];
$threadforum = $forum_info_array["title"];
$threadiconid = $latest_array["iconid"];
// split apart long URL strings
$newstext=eregi_replace("\\[url\\]www.([^\\[]*)\\[/url\\]","<a href=\"http://www.\\1\" target=_blank>\\1</a>",$newstext);
$newstext=eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=_blank>(hyperlink)</a>",$text);
$newstext=eregi_replace("\\[url=\"([^\"]*)\"\\]([^\\[]*)\\[\\/url\\]","<a href=\"\\1\" target=_blank>\\2</a>",$newstext);
$newstext=eregi_replace("\\[url=([^\"]*)\\]([^\\[]*)\\[\\/url\\]","<a href=\"\\1\" target=_blank>(hyperlink)</a>",$newstext);
//special thank-you to Menno at vBulletin Community Forum for coming up with the above part!
if ($threadiconid==0) {
$threadicon = "";
}
else {
$threadicon = "<img src=\"/bbs/images/icons/icon$threadiconid.gif\" alt=\"Thread icon\"> ";
}
if ($newscomments==1) {
$commenttext = "reply";
}
else {
$commenttext = "replies";
}
print("
<table width=\"90%%\" cellpadding=\"2\" BORDER=0 ALIGN=CENTER>
<tr><td width=\"100%%\" bgcolor=\"#99CCFF\" class=\"sidebar1\">
<FONT SIZE=-1><B>Subject: $newstitle</B></FONT><br>
</td></tr><tr>
<td width=\"100%%\" class=\"sidebar1\" bgcolor=\"#f7f7f7\">
<FONT SIZE=-1>Read the <a href=\"http://www.caviesgalore.com/forums/showthread.php?threadid=$newsthreadid\" class=\"sidebar1\">$newscomments $commenttext</a><br></FONT>
</td></tr></table>
");
}
?>
Warning: Cannot add header information - headers already sent by (output started at /home2/cavy4me/public_html/index.php:7) in /home2/cavy4me/public_html/forums/global.php on line 1495
Warning: Cannot add header information - headers already sent by (output started at /home2/cavy4me/public_html/index.php:7) in /home2/cavy4me/public_html/forums/global.php on line 1501
When I try to display the last 4 posts. The code I'm using is, what can I do?:
<?
chdir("/home/cavy4me/public_html/forums/");
include("global.php");
$num_active = 4;
$num_chars = 40;
$db=mysql_connect($servername,$dbusername,$dbpassw ord);
mysql_select_db($dbname);
$querylatest="SELECT * FROM thread WHERE forumid='1' OR forumid='2' OR forumid='3' OR forumid='4' OR forumid='5' OR forumid='6' OR forumid='10' ORDER BY lastpost DESC LIMIT $num_active";
$resultlatest = mysql_query($querylatest,$db);
while ($latest_array = mysql_fetch_array($resultlatest)) {
// Get Forum Infomation
$query_forum = "select * from forum where forumid='$latest_array[forumid]'";
$result_forum = mysql_query($query_forum,$db);
$forum_info_array = mysql_fetch_array($result_forum);
// split the date up a bit
$datestr1 = substr($latest_array["dateline"],0,10);
$datetime = substr($latest_array["dateline"],11,8);
$querythread="SELECT * FROM post WHERE threadid='$latest_array[threadid]' ORDER BY dateline ASC LIMIT 1";
$result_thread_text= mysql_query($querythread,$db);
$result_thread_array = mysql_fetch_array($result_thread_text);
$newstitle = $latest_array["title"];
$newsposter = $latest_array["postusername"];
$newsposterid = $result_thread_array["userid"];
$newsdate = date("D j M Y", $latest_array["dateline"]);
$newstext = substr(strip_tags($result_thread_array["pagetext"]),0,$num_chars);
$newsthreadid = $latest_array["threadid"];
$newscomments = $latest_array["replycount"];
$threadforumid = $latest_array["forumid"];
$threadforum = $forum_info_array["title"];
$threadiconid = $latest_array["iconid"];
// split apart long URL strings
$newstext=eregi_replace("\\[url\\]www.([^\\[]*)\\[/url\\]","<a href=\"http://www.\\1\" target=_blank>\\1</a>",$newstext);
$newstext=eregi_replace("\\[url\\]([^\\[]*)\\[/url\\]","<a href=\"\\1\" target=_blank>(hyperlink)</a>",$text);
$newstext=eregi_replace("\\[url=\"([^\"]*)\"\\]([^\\[]*)\\[\\/url\\]","<a href=\"\\1\" target=_blank>\\2</a>",$newstext);
$newstext=eregi_replace("\\[url=([^\"]*)\\]([^\\[]*)\\[\\/url\\]","<a href=\"\\1\" target=_blank>(hyperlink)</a>",$newstext);
//special thank-you to Menno at vBulletin Community Forum for coming up with the above part!
if ($threadiconid==0) {
$threadicon = "";
}
else {
$threadicon = "<img src=\"/bbs/images/icons/icon$threadiconid.gif\" alt=\"Thread icon\"> ";
}
if ($newscomments==1) {
$commenttext = "reply";
}
else {
$commenttext = "replies";
}
print("
<table width=\"90%%\" cellpadding=\"2\" BORDER=0 ALIGN=CENTER>
<tr><td width=\"100%%\" bgcolor=\"#99CCFF\" class=\"sidebar1\">
<FONT SIZE=-1><B>Subject: $newstitle</B></FONT><br>
</td></tr><tr>
<td width=\"100%%\" class=\"sidebar1\" bgcolor=\"#f7f7f7\">
<FONT SIZE=-1>Read the <a href=\"http://www.caviesgalore.com/forums/showthread.php?threadid=$newsthreadid\" class=\"sidebar1\">$newscomments $commenttext</a><br></FONT>
</td></tr></table>
");
}
?>