Cannot modify header

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
cesarcesar
Forum Contributor
Posts: 111
Joined: Mon Oct 18, 2004 3:28 pm

Cannot modify header

Post by cesarcesar »

I have a page I'm calling headers on. I'm getting the error
PHP Warning: Cannot modify header information - headers already sent by
So i use headers_sent() to see where the issue is. It says line 1. At line 1 I only have a <?php on the line with NO white space before it. more test.. same error. I then remove everything and only have one line of code with a header(Location:http://www.blabla.com) on line 1. Again no white space before or after PHP. Still the same error.

Why is this happening? Why are my headers failing? Thanks much.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Cannot modify header

Post by Christopher »

Check all the files you include before the header() call too. make sure you also don't have a space or newline after an ?> at the end of a file .
(#10850)
cesarcesar
Forum Contributor
Posts: 111
Joined: Mon Oct 18, 2004 3:28 pm

Re: Cannot modify header

Post by cesarcesar »

Found the problem. Thanks to all those that helped.

Basically there was some type of invisible character in the beginning of my file. I copied all of the file but the first and last character, then pasted into a new doc. Saved over the old doc and it works!

I'm using EditPlus3 text editor in case anyone knows why this invisible char was added.
Post Reply