Web Hosting Talk







View Full Version : php, question about header function


feelexit
09-09-2005, 09:42 AM
Warning: Cannot modify header information - headers already sent by (output started at /home/feelexit/public_html/setup.php:43) in /home/feelexit/public_html/member.php on line 11


if (CheckAuth() != 'Y')
{
header("Location: http://www.qjcreative.com/login.html");
}


it runs fine on my local machine. after i upload it. i have problem.

I dont know why i cannot modify header information.

laserlight
09-09-2005, 09:55 AM
it runs fine on my local machine. after i upload it. i have problem.
That's strange. Still, you can do the usual - check that your script doesnt ouput anything before the header() call. In particular, check for whitespace at the top, including blank lines.

Azavia
09-09-2005, 11:52 AM
Or if a file was included before that code, make sure there is no whitespace at the end of that file. for instance, you might have included a blank line after the ?>.

I believe there is a setting to have it automatically use output buffering, so you can use the header function anywhere. Your computer may have this enabled.

Marble
09-09-2005, 12:02 PM
Originally posted by feelexit
Warning: Cannot modify header information - headers already sent by (output started at /home/feelexit/public_html/setup.php:43) in /home/feelexit/public_html/member.php on line 11


if (CheckAuth() != 'Y')
{
header("Location: http://www.qjcreative.com/login.html");
}


it runs fine on my local machine. after i upload it. i have problem.

I dont know why i cannot modify header information.

Because as stated there is probably some white space or some html that is already sent out. You can turn on output buffering:

ob_start();


and at the end of your file:

ob_end_flush();

That will get rid of any of those header warnings by buffering the output before sending it out.

innova
09-09-2005, 01:00 PM
Better yet find the blank line in setup.php :)

That OB stuff is a hack that you dont need to use (in this situation).

innova
09-09-2005, 01:00 PM
##double post##