Headers already sent, this is driving me nuts

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
User avatar
Uranium-235
Forum Newbie
Posts: 13
Joined: Tue Aug 08, 2006 3:57 pm

Headers already sent, this is driving me nuts

Post by Uranium-235 »

I've been working on a project, when I started to use header, it says they've already been sent (on line 1). I've encountered this kind of thing before, but this time, I could not see a reason why. I eventually got the code down as small as I can ge it, and it STILL does it. There's no reason it should be doing this.

Code: Select all

<?php
	header("location: /");

?>
(no, there's no space infront of the <?php)

when I put nothing between the <?php and ?>, moz says the document is 3 bytes, which means something is being sent, but I don't see how or where. Does anyone have any idea?
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post by GeXus »

User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Does you PHP config have an auto prepend file?
(#10850)
User avatar
Uranium-235
Forum Newbie
Posts: 13
Joined: Tue Aug 08, 2006 3:57 pm

Post by Uranium-235 »

GeXus: I already said there's nothing infront of the open tag, which is why this is so fustrating. I even opened it in IE, went to view source so I could get UltraEdit to open it up, and UE says 2 bytes, but I don't see any characters

arborint: both prepend and append are null
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Did you happen to save the file in UTF-8? If so, I'd bet there's a BOM in your file.
User avatar
Uranium-235
Forum Newbie
Posts: 13
Joined: Tue Aug 08, 2006 3:57 pm

Post by Uranium-235 »

heh, yeah that's it. I actually discovered it a few minutes ago

Ultraedit is acting wierd with this, and only this file. All other files i've FTP saved with UE to this server are 'DOS'. But this one file is being saved as UTF8-DOS. I can use the UE convert to convert it to DOS, and it will work. but if I close UE out and open the file back up, it opens it up as UTF8. Wierd.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I'd also suggest you read this thread as it pertains to your code.
User avatar
Uranium-235
Forum Newbie
Posts: 13
Joined: Tue Aug 08, 2006 3:57 pm

Post by Uranium-235 »

you're talking about the fact i'm redirecting to '/'?

actually that was for sheer testing purposes. I was narrowing this problem as far as I can, and just chose to test the re-direct to the site root. In the actual full script I'm using $PHP_SELF, which is the full URI (though thanks for the link cause I usually don't use exit, even though alot of these header redirects don't have anything to execute after them, but I guess I should go ahead and use exit; anyways).

I went into Ultraedit's options, and disabled auto-detect for UTF-8, which seems to have fixed my problem, though why this problem came up, I have no idea, first time it has any any of these servers i've worked on, and i've worked on them alot.
Post Reply