Jump to content

header ()


westman

Recommended Posts

The error message says that there is output, therefore there is obviously output somewhere. You better look more carefully at your code. Output can also include spaces and line breaks.It even tells you where the output occurred:output started at /home/content/31/9408631/html/....../index.php:2

Link to comment
Share on other sites

  • Replies 59
  • Created
  • Last Reply

Top Posters In This Topic

i just opened a new folder and a new index.php in it with 1 line of code... <?php header("location: ../user/index.php?id=$id");?>and i got....Warning: Cannot modify header information - headers already sent by (output started at /home/content/31/9408631/html/testpage/index.php:2) in /home/content/31/9408631/html/testpage/index.php on line 3 how do i stop this error happening?

Link to comment
Share on other sites

Go to index.php on line 2 and look for whatever is causing an output.Or post lines 1, 2 and 3 here so we can point it out. your header() function is on line 3, so there are two lines before it.

Link to comment
Share on other sites

check for white space also, prolly have a space somewhere on index.php line 2, as foxy said. for me i normally check for the white spaces at the end of every closing, also from what i have experience echoing doesnt really bother the header(). its normally what donE's example show on the 1st page so on line 1 n 2 check for the spaces

Link to comment
Share on other sites

it could be how you saved the file. Make sure when you are saving it, it is without BOM.

Edited by thescientist
Link to comment
Share on other sites

west copy your code in your file and paste it into the


tags on here, we still cant see the problem since we cant view the codes

Link to comment
Share on other sites

He obviously doesn't want to show us anymore of his code. DDs1 is at least the third person that's made that request. Hmmm.

Link to comment
Share on other sites

i don't think it's a code issue at this point. he is showing us the code that the error in the original post referenced. at this point it's probably how the file is being saved.

Link to comment
Share on other sites

the issue as stated in the OP was that output has already been sent, and as such no location header can be sent. the issue now is to address where the output is coming from. If it was a path issue, the error would have made reference to not finding a page or something similar.

Link to comment
Share on other sites

Glad that thescientist brought up the BOM. Lastnight after I left here, it came to mind and was reluctant to get back on and post about that. I had a similar problem with that, with the program I was using It was saving with BOM even though I specifically set it to save without BOM. Finally switching over to another editor and saving properly, it fixed the problem.With DW though, default settings from my understanding save UTF-8 without BOM, but I could be wrong. West, you might want to check the settings in DW.

Link to comment
Share on other sites

The error message says your header() is one line 3 and the output started on line 2That means your code looks something like this:1.2. <?php3. header("location: ../user/index.php?id=$id");4. ?>

Link to comment
Share on other sites

my error is somthing i have never seen before. 1 simple line of code as you can see above in post 41 and am getting an error and i dont know why, so here is more info.... the 1 line code is on file index.php, the file is in www.mysite.com/testpage/index.php and i use godaddy for hosting is that helpful in finding the problem?

Link to comment
Share on other sites

"Line break" is the character that makes one line of text separated from another. It's like the <br> tag in HTML. It's invisible, but it's actually an output character like any other. If your <?php tag is not on the very first line of your document you are sending line breaks to the client, which is causing the headers to already be sent.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...