Page 1 of 1

Warning: Cannot modify header information...

Posted: Thu Aug 30, 2007 7:54 am
by canadiancoder
Hi Folks,

My computer recently crashed and I had restored my code from a backup that I had confirmed worked. Now I get the following message:

Warning: Cannot modify header information - headers already sent by (output started at C:\Project\Current\portal\content_root\includes\header.php:6) in C:\Project\Current\portal\content_root\login.php on line 50

The culprit is on this line:

...
<title><?php echo $ALLPAGES[$THISPAGE]['Title']; ?></title>
...

I've looked for a solution and found most people get this problem when they leave trailing whitespace when they close their PHP tag. I've confirmed that this is not my problem.

Can anyone suggest something else that might help? If you want more code I'll provide.

Thanks!

Posted: Thu Aug 30, 2007 8:01 am
by Bon Bon
If you have any cookies or headers being sent out after you are outputting content then you will get this message.

Do a quick search for header(), session_register and $_SESSION and make sure nothing is trying to output before them.

Posted: Thu Aug 30, 2007 8:27 am
by canadiancoder
Hi Bon Bon,

Yeah I looked for those details and everything is in order. What I did to finally fix it is increase the buffer size in php.ini. I set:

output_buffering = 16384

And that cleared the problem.

Posted: Thu Aug 30, 2007 8:36 am
by feyd
Output buffering is a temporary "fix." The error you posted specifically states that output started in header.php at line 6.