Php header() problem

Hi. I’m developing a site in PHP/mySQL and have come across something that i cannot figure out. On a different site (running as cgi) I have some simple authentication that works as expected. I copied the files to the new site (not running as cgi) thinking that they would just plug in and work.

I’m getting these warnings on my web page:

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/.x/x/ in /home/.x/x/ on line 7

Warning: Cannot modify header information - headers already sent by (output started at /home/.x/x/ in /home/.x/x/ on line 32

Line 1 of display.php is :

<? require($_SERVER['DOCUMENT_ROOT']."/admin/session_validate.php"); /* checks for valid session */ ?>

There is absolutely nothing before the <?.
I also deleted everything in the file except for line one and get the same result.

Line 32 is a redirect for incorrect login. header(“Location: http://www…”.

There is no output to the page, to empty lines, etc.

There is a login page with UN and PW fields. The action of the form is display.php which calls session_validate.php on line one.

As I said, this exact code works on the other site. The reason I mentioned the running as cgi is that I had a problem with a 404 error page. Could this be related?

Am I missing something?


Well, if the code is working correctly, but you still get that error, just put an @ before them so it will not announce errors… (eg. @require(“blah”);, $header(“Cache-Control: Private”):wink:

That should do the trick if the script works, but you’re receiving those errors.

I’m aware of the @ ‘solution’. I don’t think it is good coding practice to suppress error messages, but it looks like that may be what gets me to the end of this project.

Are there any other suggestions? I would only use error suppression as a very last resort.


Well I was going to reply before but you pre-emptied my comments. ANY blank lines in a file, including required files will stop you setting headers.

Maybe your setting two headers by mistake? Maybe you have two consecutive sets of if statements, and it’s going through both?