Forum Moderators: coopster

Message Too Old, No Replies

cannot modify header information

         

lokjah

9:31 pm on Sep 20, 2004 (gmt 0)

10+ Year Member



Hi everyone, Im struggling with a shoutbox ( a couple cool peeps helped me with an installation error a couple weeks ago) that I'm trying to get onto a site of mine. I'm getting a cannot modify header info warning. Ive checked for blank spaces or new lines at the beginning of my file but dont see any. Ive also read that header info must be sent before the html tag but I have tried moving some of the code around and I just get different errors. These are the lines i'm getting warnings on:


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]

hughie

10:03 pm on Sep 20, 2004 (gmt 0)

10+ Year Member



your trying to set a cookie after you've already sent a load of HTML to the browser.

Set your cookies first then, output the HTML.

ta,
Hughie

lokjah

10:20 pm on Sep 20, 2004 (gmt 0)

10+ Year Member



thanks hughie, where would be the right place to put the cookie code? I'm afraid if I paste it in the wrong place i'll create more errors..

sorry for my noob"iness"

mincklerstraat

11:29 pm on Sep 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Set your cookie as soon as you have enough information:
1) to know whether you actually want to set one or not
2) to know what the cookie info is you want to set - and before any HTML (or other) output goes out to the browser. This includes possible whitespace before the opening <?php, and whitespace after the closing?> in included files.

lokjah

11:40 pm on Sep 20, 2004 (gmt 0)

10+ Year Member



thanks for that info, albeit im not versed enough to impliment it as i'm not sure as to what the author is doing exactly with his code (again im a php noob).. i'll post the code here in hopes that it would help... i've tried moving the cookie info around but it just seems to generate more errors wherever I put it..

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>");
}
?>

lokjah

12:54 am on Sep 21, 2004 (gmt 0)

10+ Year Member



the above the is the simpleshout.php and below is the code on my html page... the warning message says that line 8 is where the output is started..that line is where my


<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>

lokjah

2:27 am on Sep 21, 2004 (gmt 0)

10+ Year Member



ok update....

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>

mincklerstraat

10:54 am on Sep 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is getting kinda complicated, lokjah. I know it must be frustrating that you can't get your shoutbox to do what you want exactly, but it's difficult to tell what's all happening with all this code with just a quick glance, which is more or less what this forum is for. However, my guess is that you're not likely to get your problem solved here just now. I'd go with a version of the shoutbox that works even though it doesn't do everything you want, and diddle around with some php scripts you write yourself, that just do real simple things to test out new functions when you learn them. Then you will eventually get the point where you can dissect this code yourself and see just what it's up to.

lokjah

2:46 pm on Sep 21, 2004 (gmt 0)

10+ Year Member



thanks mincklerstraat, after hours of googling, seeing all the whitespace angles, and the set cookie code before any html is output, I didnt think it would be too difficult for someone well versed in php to see the code that im working with and spot whats wrong..

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

jatar_k

3:57 pm on Sep 21, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



>> cannot modify header info

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.

lokjah

4:11 pm on Sep 21, 2004 (gmt 0)

10+ Year Member



thanks jatar, yes thats pretty much what ive been reading everywhere...i really dont see any whitespace that could be causing it, ive checked before and after my <? on all related pages...

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..

mincklerstraat

4:33 pm on Sep 21, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The problem then would be your putting simpleshout.php on an HTML page. The HTML will already have started output (sending stuff to the browser) before simpleshout starts running, so you get this error.

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.

lokjah

5:20 pm on Sep 21, 2004 (gmt 0)

10+ Year Member



yeah exactly.. and thats what I was trying to figure out how to do, the latter.....

and thanks for the iframe reminder, i read that in my google searches as well...

mincklerstraat

9:57 am on Sep 22, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To do the latter, you could try putting everything in the code you posted above the line #######HELP####### above everything that outputs HTML on the page you have this on - and the part below that line at the point you want your shoutbox to appear. If this doesn't work, just go directly for the iframe solution - in fact, this could even have advantages if you do things correctly - if the rest of your site doesn't use cookies, you can put this iframe in a subdomain, and then the rest of your pages aren't hampered by cookies. Makes the pages much more cache-friendly and therefore a lot faster. When only a part of the page needs to be dynamic, this is really the preferred method. Even image caching can be hampered by cookies (requests for images are also accompanied by the cookie - makes for a bit more bandwidth waste, too).

lokjah

2:50 pm on Sep 22, 2004 (gmt 0)

10+ Year Member



nice advice minck, thanks for that.. I will try it...

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...

lokjah

2:43 am on Sep 23, 2004 (gmt 0)

10+ Year Member



ok, got it solved....

I took all the code from line 83 up and put it in an include and put that include at the top of my html page...

mincklerstraat

7:41 am on Sep 25, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Good to hear you got it solved. Keep the iframe option open in your mind for future applications. It has some major benefits when it comes to site speed and web-friendliness in general, since it allows you to display dynamic information (generally uncacheable) on a page which is cacheable.

lokjah

9:59 pm on Sep 25, 2004 (gmt 0)

10+ Year Member



thanks minc i will and thanks for the help :)