Click to See Complete Forum and Search --> : [RESOLVED] LAMP vs. WAMP and page headers


scambro
03-16-2008, 04:01 PM
Hi all,

I finally took the plunge and took a spare PC to play with a LAMP setup. I've got ubuntu 7.1 server running with the LAMP pieces of the install (apache 2.2, php 5, and mysql). Same setup I have on my Windows PC. When I got all the php and sql db's moved over, I immediatly get the cannot modify headers error message.

It's appearing only on login pages where I pass the user from the main page, then to a check_user page, then to a logon page, etc. I can see where my issue is, but what confuses me is why this has worked for years on a WAMP setup and it changes on a LAMP. Is there a buffer setting perhaps in Apache that was preset in the Windows version that I could set in the Linux one?

Thanks!

NogDog
03-16-2008, 05:36 PM
My first guess would be that your FTP or other file copying process added a newline after the final "?>" of an include file. Now when you include it, that newline gets output, thus stopping headers from being sent by any command which follows the include/require of that include file. (This is why I'm now in the habit of leaving out the final ?> in all my includes.)

PS: There is a global output buffering option: http://www.php.net/manual/en/ref.outcontrol.php#ini.output-buffering

bradgrafelman
03-16-2008, 05:46 PM
Note that using output buffering to avoid the 'headers already sent' error is not a solution but rather a workaround to avoid the problem - the solution (that won't place extra load on your server by buffering all output) would be to remove whatever's being outputted.

Just look at the error message(s) being outputted - they tell you exactly what file and line is outputting data; once you find the line(s), look for blank spaces, new lines, etc. as NogDog pointed out.

scambro
03-16-2008, 07:45 PM
Thanks for the helpful info, but I think I found my misstep. On my WAMP server I had my php,ini file set to auto_start the sessions, but I didn't have this on the LAMP one. So I was checking variables that were failing eventhough I was truly logging in. That forced me to hit to multiple includes that I shouldn't have been. I added the session_start() where I needed it in a few places, and I'm good to go.

Now I have to figure out why my session_destroy's don't work anymore! :)

EDIT:
A restart of apache took care of that problem...