Page 1 of 1
Header
Posted: Wed Mar 19, 2003 12:59 pm
by taboas
The following error appears
Warning: Cannot modify header information - headers already sent by (output started
The instruction is:
mysql_close($conexion);
$vuelta = "inicio.php";
header("Location: ". $vuelta);
exit;
Posted: Wed Mar 19, 2003 3:34 pm
by bionicdonkey
header can only be send before any output has been sent to the browser...i think
Posted: Wed Mar 19, 2003 3:40 pm
by daven
BD: you are correct. The header() function only works before any output is sent.
Posted: Thu Mar 20, 2003 2:17 am
by twigletmac
Posted: Thu Mar 20, 2003 4:27 am
by sleepingdanny
More
easy explantion:
"header()" is need to be placed above the <html> tag or it will show the error...
1) mysql_close($conexion);
2) $vuelta = "inicio.php";
3) header("Location: ". $vuelta);
4) exit;
<html>
<head>
.....
The 3rd line is wrong - it should be
header("Location: . $vuelta"); and not
header("Location: ". $vuelta);
Posted: Thu Mar 20, 2003 4:32 am
by twigletmac
sleepingdanny wrote:More
easy explantion:
"header()" is need to be placed above the <html> tag or it will show the error...
That's a simple explanation but you can still get the error if you have whitespace above the <html> tag or if you echo() something above the <html> tag so it's not the
whole answer

.
Mac
Posted: Thu Mar 20, 2003 4:54 am
by sleepingdanny
I don't know if this is true because it never happend to me

Posted: Thu Mar 20, 2003 5:01 am
by twigletmac
sleepingdanny wrote:I don't know if this is true because it never happend to me

It is true - you cannot output anything (and whitespace counts as something) to the browser before calling the header() function. That is of course unless you use output buffering:
http://www.php.net/manual/en/ref.outcontrol.php
This is because PHP doesn't know HTML so it doesn't check to see if the function is being called before the <html> tag, it checks to see if the function is being called before there is any output to the browser.
Mac