Forum Moderators: coopster
Warning: Cannot modify header information - headers already sent by (output started at /home/aenonf2/public_html/shout/index.php:8) in /home/aenonf2/public_html/shout/simpleshout.php on line 79
Warning: Cannot modify header information - headers already sent by (output started at /home/aenonf2/public_html/shout/index.php:8) in /home/aenonf2/public_html/shout/simpleshout.php on line 81
Warning: Cannot modify header information - headers already sent by (output started at /home/aenonf2/public_html/shout/index.php:8) in /home/aenonf2/public_html/shout/simpleshout.php on line 83 my php coding experience is nil as I only use it thus far for includes (which ROCK)...
I have cleaned up the shoutbox to make it xhtml 1 compliant which was my biggest adventure yet into the code... Ive written the author of the shoutbox but didnt get any response, I offered him the xhtml compliant version also...
If some kind soul could look at it I'd really appreciate the help immensely....this is a test page, on the real site I will be using an include..
<snip>
the warning happens when you enter your shout and click "shout it out"...
strange thing is that on another site of mine which is hosted on powweb it works fine, powweb is using PHP v4.3.8
and so is lunarpages (where I am currently having the problem, ive contacted them but they say its a code problem and wouldnt help me other than point me to their forum)
thanks alot...
løk
[edited by: jatar_k at 10:59 pm (utc) on Sep. 20, 2004]
[edit reason] no personal urls thanks [/edit]
i'd be glad to help out with css and xhtml if anyone needs help... thats more my thing hehe...
<?
/* VNETShoutBox 1.0 Mod From SimpleShoutBox Copyright (C) 2004 Wisdom K. All Rights Reserved */
/* Vionetwork is not responsible for any damage or loss of data!*/
/* This Script was made by VioAdmin owner of Vionetwork.com */
/* */require("config.php");
function phrase($sbshout) {
global $ssb;
$sbshout=str_replace(":)", "<img src=\"./smilies/smile.gif\" alt=\"smilie\" />",$sbshout);
$sbshout=str_replace(":(", "<img src=\"./smilies/frown.gif\" alt=\"smilie\" />",$sbshout);
$sbshout=str_replace(";)", "<img src=\"./smilies/wink.gif\" alt=\"smilie\" />",$sbshout);
$sbshout=str_replace(":¦", "<img src=\"./smilies/plain.gif\" alt=\"smilie\" />",$sbshout);
$sbshout=str_replace(":@", "<img src=\"./smilies/mad.gif\" alt=\"smilie\" />",$sbshout);
$sbshout=str_replace(":D", "<img src=\"./smilies/grin.gif\" alt=\"smilie\" />",$sbshout);
$sbshout=str_replace(":p", "<img src=\"./smilies/toung.gif\" alt=\"smilie\" />",$sbshout);
$sbshout=str_replace(":eek:", "<img src=\"./smilies/eek.gif\" alt=\"smilie\" />",$sbshout);
$sbshout=str_replace(":rolleyes:", "<img src=\"./smilies/rolleyes.gif\" alt=\"smilie\" />",$sbshout);
$sbshout=str_replace(":confused:", "<img src=\"./smilies/confused.gif\" alt=\"smilie\" />",$sbshout);
$sbshout=str_replace(":laugh:", "<img src=\"./smilies/laugh.gif\" alt=\"smilie\" />",$sbshout);
$sbshout=str_replace(":cool:", "<img src=\"./smilies/cool.gif\" alt=\"smilie\" />",$sbshout);
$sbshout=str_replace("[b]", "<b>", "$sbshout");
$sbshout=str_replace("[/b]", "</b>", "$sbshout");
$sbshout=str_replace("[i]", "<i>", "$sbshout");
$sbshout=str_replace("[/i]", "</i>", "$sbshout");
$sbshout=str_replace("[u]", "<u>", "$sbshout");
$sbshout=str_replace("[/u]", "</u>", "$sbshout");
$sbshout=str_replace("[move]", "<marquee>", "$sbshout");
$sbshout=str_replace("[/move]", "</marquee>", "$sbshout");
$sbshout=str_replace("javascript:", "javascript :", "$sbshout");
$sbshout=str_replace("vbscript:", "vbscript :", "$sbshout");
$sbshout=str_replace("about:", "about :", "$sbshout");
$sbshout=eregi_replace("(^¦[>[:space:]\n])([[:alnum:]]+)://([^[:space:]]*)([[:alnum:]#?/&=])([<[:space:]\n]¦$)","\\1<a href=\"\\2://\\3\\4\" target=\"_blank\">\\2://\\3\\4</a>\\5", $sbshout);
$sbshout=eregi_replace( "(([a-z0-9_]¦\-¦\.)+@([^[:space:]]*)([[:alnum:]-]))", "<a href=\"mailto:\\1\">\\1</a>", $sbshout);
return($sbshout);
}
function filter($sbshout) {
global $ssb;
$filters=mysql_query("SELECT * FROM $ssb[pre]_filter");
while($filter=mysql_fetch_array($filters)) {
htmlspecialchars(stripslashes(extract($filter)));
$sbshout=eregi_replace($find,$replacewith,$sbshout);
}
return($sbshout);
}
If ($_POST['doshout']) {
extract($_POST);
If(empty($sbname) ¦¦ $sbname=="Your Name / Nick") {
$error="1";
$error_text .= "Type Your name!<br />";
}
If (empty($sbshout) ¦¦ $sbshout=="Your Message") {
$error="1";
$error_text .= "Type A Message!<br />";
}
If ($sburl!=="Website URL" && $sburl) {
If (empty($sburl) ¦¦!preg_match('#^http+://#si', $sburl)) {
$error="1";
$error_text .= "Invalid Website";
}
}
If ($sburl=="Website URL") {
$sbiurl = "";
} Else {
$sbiurl = "$sburl";
}
If ($error=="1") {
$show_errors = "<tr class=\"error\" align=\"center\"><td>$error_text</td></tr>";
} Else {
mysql_query("INSERT INTO $ssb[pre]_shout VALUES('NULL', '$sbname', '$sbiurl', '$sbshout', '".time()."', '$_SERVER[REMOTE_ADDR]')");
setcookie("ssbname",$sbname,time()+108000);
If($sburl){setcookie("ssburl",$sburl,time()+108000);}
header("Location: $_SERVER[PHP_SELF]?cmd=$ssb[cmd]");
exit();
}
}
########## H E L P ##########
If ($ssb[cmd]=="extras") {
Echo("<table border=\"1\" cellpadding=\"1\" cellspacing=\"0\" style=\"border-collapse: collapse\" width=\"100%\" align=\"center\">\n");
Echo("<tr bgcolor=\"$ssb[th]\">\n");
Echo("<td colspan=\"2\" align=\"center\" class=\"reg\"><b>VNETShoutBox Extras</b></td>\n");
Echo("</tr>\n");
Echo("<tr bgcolor=\"$ssb[th]\">\n");
Echo("<td colspan=\"2\" class=\"reg\">VNETShoutBox Smilies:</td>\n");
Echo("</tr>\n");
Echo("<tr class=\"small\" align=\"center\" bgcolor=\"$ssb[tb]\">\n");
Echo("<td width=\"70%\">:)</td>\n");
Echo("<td width=\"30%\"><a href=\"javascript:smiley(':)')\"><img src=\"./smilies/smile.gif\" border=\"0\"></a></td>\n");
Echo("</tr>\n");
Echo("<tr class=\"small\" align=\"center\" bgcolor=\"$ssb[tb]\">\n");
Echo("<td>:(</td>\n");
Echo("<td><a href=\"javascript:smiley(':)')\"><img src=\"./smilies/frown.gif\" border=\"0\"></a></td>\n");
Echo("</tr>\n");
Echo("<tr class=\"small\" align=\"center\" bgcolor=\"$ssb[tb]\">\n");
Echo("<td>;)</td>\n");
Echo("<td><a href=\"javascript:smiley(';)')\"><img src=\"./smilies/wink.gif\" border=\"0\"></a></td>\n");
Echo("</tr>\n");
Echo("<tr class=\"small\" align=\"center\" bgcolor=\"$ssb[tb]\">\n");
Echo("<td>:¦</td>\n");
Echo("<td><a href=\"javascript:smiley(':¦')\"><img src=\"./smilies/plain.gif\" border=\"0\"></a></td>\n");
Echo("</tr>\n");
Echo("<tr class=\"small\" align=\"center\" bgcolor=\"$ssb[tb]\">\n");
Echo("<td>:@</td>\n");
Echo("<td><a href=\"javascript:smiley(':@')\"><img src=\"./smilies/mad.gif\" border=\"0\"></a></td>\n");
Echo("</tr>\n");
Echo("<tr class=\"small\" align=\"center\" bgcolor=\"$ssb[tb]\">\n");
Echo("<td>:D</td>\n");
Echo("<td><a href=\"javascript:smiley(':D')\"><img src=\"./smilies/grin.gif\" border=\"0\"></a></td>\n");
Echo("</tr>\n");
Echo("<tr class=\"small\" align=\"center\" bgcolor=\"$ssb[tb]\">\n");
Echo("<td>:p</td>\n");
Echo("<td><a href=\"javascript:smiley(':p')\"><img src=\"./smilies/toung.gif\" border=\"0\"></a></td>\n");
Echo("</tr>\n");
Echo("<tr class=\"small\" align=\"center\" bgcolor=\"$ssb[tb]\">\n");
Echo("<td>:eek:</td>\n");
Echo("<td><a href=\"javascript:smiley(':eek:')\"><img src=\"./smilies/eek.gif\" border=\"0\"></a></td>\n");
Echo("</tr>\n");
Echo("<tr class=\"small\" align=\"center\" bgcolor=\"$ssb[tb]\">\n");
Echo("<td>:rolleyes:</td>\n");
Echo("<td><a href=\"javascript:smiley(':rolleyes:')\"><img src=\"./smilies/rolleyes.gif\" border=\"0\"></a></td>\n");
Echo("</tr>\n");
Echo("<tr class=\"small\" align=\"center\" bgcolor=\"$ssb[tb]\">\n");
Echo("<td>:confused:</td>\n");
Echo("<td><a href=\"javascript:smiley(':confused:')\"><img src=\"./smilies/confused.gif\" border=\"0\"></a></td>\n");
Echo("</tr>\n");
Echo("<tr class=\"small\" align=\"center\" bgcolor=\"$ssb[tb]\">\n");
Echo("<td>:laugh:</td>\n");
Echo("<td><a href=\"javascript:smiley(':laugh:')\"><img src=\"./smilies/laugh.gif\" border=\"0\"></a></td>\n");
Echo("</tr>\n");
Echo("<tr class=\"small\" align=\"center\" bgcolor=\"$ssb[tb]\">\n");
Echo("<td>:cool:</td>\n");
Echo("<td><a href=\"javascript:smiley(':cool:')\"><img src=\"./smilies/cool.gif\" border=\"0\"></a></td>\n");
Echo("</tr>\n");
Echo("<tr bgcolor=\"$ssb[th]\">\n");
Echo("<td colspan=\"2\" class=\"reg\">VNETShoutBox Code:</td>\n");
Echo("</tr>\n");
Echo("<tr class=\"small\" align=\"center\" bgcolor=\"$ssb[tb]\">\n");
Echo("<td colspan=\"2\" align=\"center\">[b]<b>Bold</b>[/b]</td>\n");
Echo("</tr>\n");
Echo("<tr class=\"small\" align=\"center\" bgcolor=\"$ssb[tb]\">\n");
Echo("<td colspan=\"2\" align=\"center\">[i]<i>Italics</i>[/i]</td>\n");
Echo("</tr>\n");
Echo("<tr class=\"small\" align=\"center\" bgcolor=\"$ssb[tb]\">\n");
Echo("<td colspan=\"2\" align=\"center\">[u]<u>Underline</u>[/u]</td>\n");
Echo("</tr>\n");
Echo("<tr class=\"small\" align=\"center\" bgcolor=\"$ssb[tb]\">\n");
Echo("<td colspan=\"2\" align=\"center\">[move]<marquee>Move</marquee>[/move]</td>\n");
Echo("</tr>\n");
Echo("<tr>\n");
Echo("<td colspan=\"2\" bgcolor=\"$ssb[th]\" align=\"center\"><b><a href=\"javascript:
window.close()\"><font class=\"reg\">Close Window</font></a></b></td>\n");
Echo("</tr>\n");
Echo("<tr>\n");
Echo("<td colspan=\"2\" bgcolor=\"$ssb[th]\" align=\"center\" class=\"small\">Powered By: <a href=\"http://www.vionetwork.com\" target=\"_blank\">VNETShoutBox</a> $ssb[ver]</td>\n");
Echo("</tr>\n");
Echo("</table>\n");
########## V I E W S H O U T S ##########
} Else {
Echo("<table border=\"1\" cellpadding=\"1\" cellspacing=\"0\" style=\"border-collapse: collapse\" width=\"100%\" class=\"small\" bgcolor=\"$ssb[tb]\">\n");
$total_shouts=mysql_num_rows(mysql_query("SELECT * FROM $ssb[pre]_shout"));
$total=$total_shouts-$ssb[max];
If ($ssb[direction]) {
$all="DESC";
If ($total_shouts < $ssb[max]) {
$extra="DESC";
} Else {
$extra="DESC LIMIT 0,$ssb[max]";
}
} Else {
$all="ASC";
If($total_shouts < $ssb[max]) {
$extra="ASC";
} Else {
$extra="ASC LIMIT $total,$ssb[max]";
}
}
If($ssb[cmd]=="all") {
$shouts=mysql_query("SELECT * FROM $ssb[pre]_shout ORDER BY sbid $all");
} Else {
$shouts=mysql_query("SELECT * FROM $ssb[pre]_shout ORDER BY sbid $extra");
}
while($shout=mysql_fetch_array($shouts)) {
extract($shout);
$sbdate=date("l, F dS Y, g:ia", $sbdate);
$sbbg=($i++ & 1)? "$ssb[th]" : "$ssb[tb]";
$sbshout=htmlspecialchars($sbshout);
$findurl=explode(" ",$sbshout);
for($words=0; $words<count($findurl); $words++) {
If(substr($findurl[$words],0,4)=="www."){
$foundurl="http://".$findurl[$words];
$findurl[$words]=$foundurl;
}
}
$sbshout=implode(" ",$findurl);
$sbshout=phrase($sbshout);
If($ssb[filter]){
$sbshout=filter($sbshout);
$sbname=filter($sbname);
}
$sbshout=wordwrap($sbshout, 22, "\n", 1);
If (eregi("^http://", $sburl)) {
$sbname="<a href=\"$sburl\" target=\"_blank\">$sbname</a>";
}
Echo("<tr bgcolor=\"$sbbg\">\n");
Echo("<td title=\"Posted $sbdate, IP Logged\"><b>$sbname</b> $sbshout</td>\n");
Echo("</tr>\n");
}
Echo("$show_errors");
Echo("<tr class=\"small\">\n");
Echo("<td align=\"center\" class=\"small\">\n");
Echo("<form method=\"post\" action=\"$_SERVER[PHP_SELF]?cmd=$ssb[cmd]\" name=\"sbform\">\n");
If ($_COOKIE['ssbname']) {
$sbname=$_COOKIE['ssbname'];
} Else {
$sbname="Your Name / Nick";
}
If ($_COOKIE['ssburl']) {
$sburl=$_COOKIE['ssburl'];
} Else {
$sburl="Website URL";
}
Echo("<input type=\"text\" name=\"sbname\" size=\"22\" onfocus=\"Clear(this)\" value=\"$sbname\" class=\"input\" /><br />\n");
Echo("<input type=\"text\" name=\"sbshout\" size=\"22\" onfocus=\"Clear(this)\" value=\"Your Message\" class=\"input\" /><br />\n");
Echo("<input type=\"text\" name=\"sburl\" size=\"22\" onfocus=\"Clear(this)\" value=\"$sburl\" class=\"input\" /><br />\n");
Echo("<input type=\"submit\" name=\"doshout\" value=\" Shout It Out! \" class=\"input\" /><br />\n");
If ($ssb[cmd]=="all") {
Echo("<a href=\"javascript:void(0);\" onclick=\"Extras('$_SERVER[PHP_SELF]?cmd=extras',200,335)\">Extras</a> ¦ <a href=\"$_SERVER[PHP_SELF]\">Limit Shouts</a>\n");
} Else {
Echo("<a href=\"javascript:void(0);\" onclick=\"Extras('$_SERVER[PHP_SELF]?cmd=extras',200,335)\">Extras</a> ¦ <a href=\"$_SERVER[PHP_SELF]?cmd=all\">All Shouts</a>\n");
}
Echo("</form>\n");
Echo("</td>\n");
Echo("</tr>\n");
Echo("</table>");
}
?>
<style type="text/css" media="screen">
is, and if i take that out the warning still generates whatever replaces that line, ex- when i take out the style and move up the javascript to that line the shoutbox still says line 8 is where the output starts.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>shizzOUT</title>
<meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" /><style type="text/css" media="screen">
#shout {
width: 200px;
height: 300px;
float: left;
padding: 10px;
overflow: auto;
}
</style>
<script type="text/javascript">
function Clear(thefield){
if (thefield.defaultValue==thefield.value)
thefield.value = ""
}
var WinNum=0;
function Extras(Url,x,y){
var String;
String = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,";
String += ",width=";
String += x;
String += ",height=";
String += y;
WinPic=window.open(Url,WinNum++,String);
}
function smiley(img) {
opener.document.sbform.sbshout.value += ' ' + img + ' ';
}
</script>
<link rel="stylesheet" href="simpleshout.css" type="text/css" />
</head>
<body>
<div id="shout">
<?php include ("simpleshout.php");?>
</div>
</body>
</html>
if i go to the file directly in my url..
mysite etc/simpleshout.php
it works.
line 8 is where the warning is saying the output is starting, and no matter how i adjust the spacing in my xhtml page it throws the warning on line 8 still
1: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2: "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3: <html xmlns="http://www.w3.org/1999/xhtml">
4: <head>
5: <title>shizzOUT</title>
6: <meta http-equiv="Content-type" content="text/html; charset=iso-8859-1" />
7:
8: <style type="text/css" media="screen">
9:
10: #shout {
11: width: 200px;
12: height: 300px;
13: float: left;
14: padding: 10px;
15: overflow: auto;
16: }
17: </style>
18:
19: <script type="text/javascript">
20: function Clear(thefield){
21: if (thefield.defaultValue==thefield.value)
22: thefield.value = ""
23: }
24: var WinNum=0;
25: function Extras(Url,x,y){
26: var String;
27: String = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,copyhistory=0,";
28: String += ",width=";
29: String += x;
30: String += ",height=";
31: String += y;
32: WinPic=window.open(Url,WinNum++,String);
33: }
34: function smiley(img) {
35: opener.document.sbform.sbshout.value += ' ' + img + ' ';
36: }
37: </script>
38:
39: <link rel="stylesheet" href="simpleshout.css" type="text/css" />
40:
41: </head>
42: <body>
43:
44: <div id="shout">
45: <table border="1" cellpadding="1" cellspacing="0" style="border-collapse: collapse" width="100%" class="small" bgcolor="#FFFFFF">
46: <tr bgcolor="#FFFFFF">
47: <td title="Posted Monday, September 20th 2004, 5:19pm, IP Logged"><b>tester7</b> once more</td>
48: </tr>
49: <tr bgcolor="#FFFFFF">
50: <td title="Posted Monday, September 20th 2004, 5:18pm, IP Logged"><b>tester6</b> again</td>
51: </tr>
52: <tr bgcolor="#FFFFFF">
53: <td title="Posted Monday, September 20th 2004, 5:18pm, IP Logged"><b>tester5</b> try again</td>
54: </tr>
55: <tr bgcolor="#FFFFFF">
56: <td title="Posted Monday, September 20th 2004, 5:01pm, IP Logged"><b>tester4</b> no cookies</td>
57: </tr>
58: <tr bgcolor="#FFFFFF">
59: <td title="Posted Monday, September 20th 2004, 5:01pm, IP Logged"><b>tester4</b> no cookies</td>
60: </tr>
61: <tr class="small">
62: <td align="center" class="small">
63: <form method="post" action="/shout/index.php?cmd=" name="sbform">
64: <input type="text" name="sbname" size="22" onfocus="Clear(this)" value="Your Name / Nick" class="input" /><br />
65: <input type="text" name="sbshout" size="22" onfocus="Clear(this)" value="Your Message" class="input" /><br />
66: <input type="text" name="sburl" size="22" onfocus="Clear(this)" value="Website URL" class="input" /><br />
67: <input type="submit" name="doshout" value=" Shout It Out! " class="input" /><br />
68: <a href="javascript:void(0);" onclick="Extras('/shout/index.php?cmd=extras',200,335)">Extras</a> ¦ <a href="/shout/index.php?cmd=all">All Shouts</a>
69: </form>
70: </td>
71: </tr>
72: </table></div>
73: </body>
74: </html>
the simpleshout.php is located in the "shout" div:
<div id="shout">
<?php include ("simpleshout.php");?>
</div>
cannot modify header info, seems to be a very common warning message... and as it is common I want to learn whats making it occur so as to help me with php...
I did alot of searching to find this shoutbox, put the time in to get it to validate and want to make it work....
would appreciate it if anyone else could lend a hand...
many thanks
løk
That normally means you have output something to the browser, which means headers get sent. Then you try to use a function that must be used before headers are sent.
The line that is reported as having the error will be the second part - the function needing to be sent before output to browser.
Therefore, start from that function and move your way upwards in the script to find the output. Remember, even whitespace before your opening <? is considered output to the client browser.
the warning on line 8 occurs when i put the simpleshout.php on an html page, line 8 on the html page refers to where i have my style type declaration, whatever i do to that html page (removing the style for example) always generates that error, on that line... line 8 in the simpleshout doesnt have any white space, ive removed any that i found...
linking directly to simpleshout.php works.. with no warnings....
the three lines (79,81,83) that the warning refers to in the simpleshout.php are these and im lead to believe that this is what I have to reorder as you mentioned above but I have no clue how to do that...
If ($error=="1") {
$show_errors = "<tr class=\"error\" align=\"center\"><td>$error_text</td></tr>";
} Else {
mysql_query("INSERT INTO $ssb[pre]_shout VALUES('NULL', '$sbname', '$sbiurl', '$sbshout', '".time()."', '$_SERVER[REMOTE_ADDR]')");setcookie("ssbname",$sbname,time()+108000);
If($sburl){setcookie("ssburl",$sburl,time()+108000);}
header("Location: $_SERVER[PHP_SELF]?cmd=$ssb[cmd]");
exit();
this is pretty embarrassing posting about this as I really dont like looking so inept... but honestly i am at php..
One workaround would be simply to place this script in an iframe by itself, then you won't have previous output. Otherwise, you'd have to place the code that figures out what the output is before any output occurs in the HTML page, and then output this at the appropriate place. Much more complicated.
I tried the iframe last nite but then had a problem of how to get it to take the stylesheet.my iframe src was the simpleshout.php but when on my page the shoutbox was unstyled. I looked in simpleshout.php everywhere to find where it calls for the simpleshout.css (which it uses by default, however I put that style into my main css file on another mock page) but i couldnt find it.
only other way I knew how to get the iframe to get the styles was to put it on an html page which of course brings me to the same said problem of the header mod warning...