Warning: Cannot modify header information...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
canadiancoder
Forum Newbie
Posts: 6
Joined: Tue Aug 07, 2007 8:35 am

Warning: Cannot modify header information...

Post 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!
Bon Bon
Forum Commoner
Posts: 66
Joined: Sat Mar 13, 2004 10:21 pm
Location: UK

Post 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.
canadiancoder
Forum Newbie
Posts: 6
Joined: Tue Aug 07, 2007 8:35 am

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Output buffering is a temporary "fix." The error you posted specifically states that output started in header.php at line 6.
Post Reply