Forum Moderators: phranque

Message Too Old, No Replies

header not working

         

andrewsmd

3:40 pm on Feb 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I just installed Apache on my machine at home and am having a problem with a header re-direct. I access this server from another machine on my LAN so basically I am going to [trogdor...]
It works fine unless I have a header in my code. If so, I get the error Warning Cannot modify header infomration - headers already sent by (output stated at C:\the path of my htdocs folder\index.php) in C:\the path of my htdocs folder\index.php on line (whatever line my header("Location: newpage.php"); )is located. Any idea why. I did have to edit my hosts file in windows on my other machine to get access to this page. Does that have anything to do with it? Thanks,

jdMorgan

5:11 pm on Feb 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, the problem is that once you send any "content" to the client from your script(s), you can no longer modify the headers. So examine your script(s) carefully, and make sure that all headers are sent before you start outputting any "HTML page" content.

Also, the server detects the "end of header transmission phase" by looking for two newline characters in a row ("\n\n") in the output stream sent to the client. Make sure that you send all headers, each ending with a single newline, and only put two newlines on the very last one.

If you need more help, feel free to post in the PHP scripting forum here at WebmasterWorld.

Jim

andrewsmd

5:42 pm on Feb 4, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The problem I have is, I have these exact same scripts on another PHP server running with apache and they work fine. I mean carbon copies minus the links. So it has to be something with my Apache.

g1smd

2:13 am on Feb 5, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Nope. It's something with your PHP.

Even if as much as one character of whitespace 'content' is sent out, it is already too late to output any more headers.

Check that your opening

<?php
tag is the very first character of the very first line in every script file on your site.