Page 1 of 1

Headers already sent, this is driving me nuts

Posted: Sun Aug 20, 2006 11:59 pm
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?

Posted: Mon Aug 21, 2006 12:02 am
by GeXus

Posted: Mon Aug 21, 2006 12:06 am
by Christopher
Does you PHP config have an auto prepend file?

Posted: Mon Aug 21, 2006 12:31 am
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

Posted: Mon Aug 21, 2006 12:36 am
by feyd
Did you happen to save the file in UTF-8? If so, I'd bet there's a BOM in your file.

Posted: Mon Aug 21, 2006 12:38 am
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.

Posted: Mon Aug 21, 2006 12:43 am
by feyd
I'd also suggest you read this thread as it pertains to your code.

Posted: Mon Aug 21, 2006 12:53 am
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.