# [SOLVED] Warning: Cannot modify header information - headers already sent by



## nbtheone (Dec 29, 2005)

I get that error when loading a php page. I understand that nothing can be output before editing the header. There are no white spaces or anything before the code. I've even tried the very basic script of:

<?php
setcookie("1", "testdata", 60*60*24*365, "/");
?>

Again, this has no white spaces before the <?php and it's on the very first line. It is not part of any include or anything. I'm thinking there must be something being output in a different file or something before hand but where do I start? Where do I look?

Thanks


----------



## Redcore (Aug 14, 2007)

*Re: Warning: Cannot modify header information - headers already sent by*

That seems bizarre if that is all that is in your PHP document...there shouldn't be any other script/file tampering with your document if this is all there is in it.


----------



## nbtheone (Dec 29, 2005)

*Re: Warning: Cannot modify header information - headers already sent by*

Yeah I know. The reason I think it might be another file is because I remember reading a website that says some servers "wrap" information around the file or something along the lines of that. The website just didn't explain or help in anyway where to look to stop this or how to stop it.


----------



## Redcore (Aug 14, 2007)

*Re: Warning: Cannot modify header information - headers already sent by*

That would be weird, because it would pretty much ruin trying to do redirections and such that are pretty standard PHP things.


----------



## nbtheone (Dec 29, 2005)

*Re: Warning: Cannot modify header information - headers already sent by*

Well, I found out what was wrong and it is such a stupid mistake! I went to save a script as a new file and noticed it was defaulting as a different encoding. I just automatically assume that Notepad defaults to ANSI. So I just resaved all my scripts as ANSI encoded files and it's all working fine now :grin:. Just shows you still need to check it when using Notepad .


----------

