You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Luis Moreira <la...@bes.pt> on 2002/08/30 12:10:58 UTC
[users@httpd] Allow Redirect
Hi
I'm using Apache 1.3 with PHP and MySQL
When using the PHP function "header" to redirect a page, I keep getting an error
Warning: Cannot add header information - headers already sent by (output started at c:\myweb\printers.php:5) in c:\myweb\printers.php on line ...
Any hints ?
Thanks
Re: [users@httpd] Allow Redirect
Posted by Chris Taylor <ch...@x-bb.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
As stated by W. Schalk.... simple errors like making sure there is NO
whitespace before the <?php to begin your header output and making
sure it's at the very start of the file.
Just a single \n before that and it'll all go horribly wrong ;)
Chris Taylor - chris@x-bb.org - The guy with the PS2 WebServer -
http://www.x-bb.org/chris.asc
- ----- Original Message -----
From: Luis Moreira
To: users@httpd.apache.org
Sent: Friday, August 30, 2002 11:10 AM
Subject: [users@httpd] Allow Redirect
Hi
I'm using Apache 1.3 with PHP and MySQL
When using the PHP function "header" to redirect a page, I keep
getting an error
Warning: Cannot add header information - headers already sent by
(output started at c:\myweb\printers.php:5) in c:\myweb\printers.php
on line ...
Any hints ?
Thanks
- ----------------------------------------------------------------------
- ----------
- ---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server
Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPW9KbSqf8lmE2RZkEQJnKwCcD2TIqHP8mrHQXpZCJYQpbFGnls8AoI4T
RNSFT0Mym7pUGqoAr3enrazl
=rngC
-----END PGP SIGNATURE-----
Re: [users@httpd] Allow Redirect
Posted by John Wards <j....@sportnetwork.net>.
ah...just remove all html you don't need it. all you need for this script is this
<?php
$agent = $_SERVER['HTTP_USER_AGENT'];
if (stristr($agent,"MSIE")){
header ("Location: ie.php");
}
else {
header ("Location: other.php");
}
?>
----- Original Message -----
From: Luis Moreira
To: users@httpd.apache.org
Sent: Friday, August 30, 2002 11:46 AM
Subject: Re: [users@httpd] Allow Redirect
1) Line 5 contains simply "<?php" instructing Apache to go into PHP mode.
I then just call this script from within the browser.
2) The string was and is at the beginning of the line, as Chris suggested.
The whole script is
/*
<html>
<body>
<?php
$agent = $_SERVER['HTTP_USER_AGENT'];
if (stristr($agent,"MSIE")){
header ("Location: ie.php");
}
else {
header ("Location: other.php");
}
?>
</body>
</html>
*/
----- Original Message -----
From: John Wards
To: users@httpd.apache.org
Sent: Friday, August 30, 2002 11:13 AM
Subject: Re: [users@httpd] Allow Redirect
whats on line 5 of printers.php? as thats your problem
Also this should be on a PHP list like php-general@lists.php.net
John Wards
SportNetwork.net
----- Original Message -----
From: Luis Moreira
To: users@httpd.apache.org
Sent: Friday, August 30, 2002 11:10 AM
Subject: [users@httpd] Allow Redirect
Hi
I'm using Apache 1.3 with PHP and MySQL
When using the PHP function "header" to redirect a page, I keep getting an error
Warning: Cannot add header information - headers already sent by (output started at c:\myweb\printers.php:5) in c:\myweb\printers.php on line ...
Any hints ?
Thanks
--------------------------------------------------------------------------
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Allow Redirect
Posted by Chris Taylor <ch...@x-bb.org>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
That's your problem, the <?php has to be the FIRST thing is
encounters.
So, a quick restructure to:
<?php
$agent = $_SERVER['HTTP_USER_AGENT'];
if (stristr($agent,"MSIE")){
header ("Location: ie.php");
}
else {
header ("Location: other.php");
}
?>
<html>
<body>
</body>
</html>
Incidentally, given that your script seems to consist of a redirect
whatever happens, there's no need at all for the <html> etc below the
?>, it won't be parsed in any case.
Chris Taylor - chris@x-bb.org - The guy with the PS2 WebServer -
http://www.x-bb.org/chris.asc
- ----- Original Message -----
From: Luis Moreira
To: users@httpd.apache.org
Sent: Friday, August 30, 2002 11:46 AM
Subject: Re: [users@httpd] Allow Redirect
1) Line 5 contains simply "<?php" instructing Apache to go into PHP
mode.
I then just call this script from within the browser.
2) The string was and is at the beginning of the line, as Chris
suggested.
The whole script is
/*
<html>
<body>
<?php
$agent = $_SERVER['HTTP_USER_AGENT'];
if (stristr($agent,"MSIE")){
header ("Location: ie.php");
}
else {
header ("Location: other.php");
}
?>
</body>
</html>
*/
- ----- Original Message -----
From: John Wards
To: users@httpd.apache.org
Sent: Friday, August 30, 2002 11:13 AM
Subject: Re: [users@httpd] Allow Redirect
whats on line 5 of printers.php? as thats your problem
Also this should be on a PHP list like php-general@lists.php.net
John Wards
SportNetwork.net
- ----- Original Message -----
From: Luis Moreira
To: users@httpd.apache.org
Sent: Friday, August 30, 2002 11:10 AM
Subject: [users@httpd] Allow Redirect
Hi
I'm using Apache 1.3 with PHP and MySQL
When using the PHP function "header" to redirect a page, I keep
getting an error
Warning: Cannot add header information - headers already sent by
(output started at c:\myweb\printers.php:5) in c:\myweb\printers.php
on line ...
Any hints ?
Thanks
- ----------------------------------------------------------------------
- ----------
- ---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server
Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPW9N3Sqf8lmE2RZkEQL1EgCgwHSomWz9mOo7rFdcrjb/7ej+l4kAoJNB
xLRhXHMY1uJWTy5/uSxWNaFc
=T9PM
-----END PGP SIGNATURE-----
RE: [users@httpd] Allow Redirect
Posted by Werner Schalk <we...@gmx.de>.
Hello,
this is an apache list, but again:
<html>
<body>
<?php
--> Sent no output to the client
before redirecting him! <html><body>
is already some output...
Bye,
Werner.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Allow Redirect
Posted by Luis Moreira <la...@bes.pt>.
1) Line 5 contains simply "<?php" instructing Apache to go into PHP mode.
I then just call this script from within the browser.
2) The string was and is at the beginning of the line, as Chris suggested.
The whole script is
/*
<html>
<body>
<?php
$agent = $_SERVER['HTTP_USER_AGENT'];
if (stristr($agent,"MSIE")){
header ("Location: ie.php");
}
else {
header ("Location: other.php");
}
?>
</body>
</html>
*/
----- Original Message -----
From: John Wards
To: users@httpd.apache.org
Sent: Friday, August 30, 2002 11:13 AM
Subject: Re: [users@httpd] Allow Redirect
whats on line 5 of printers.php? as thats your problem
Also this should be on a PHP list like php-general@lists.php.net
John Wards
SportNetwork.net
----- Original Message -----
From: Luis Moreira
To: users@httpd.apache.org
Sent: Friday, August 30, 2002 11:10 AM
Subject: [users@httpd] Allow Redirect
Hi
I'm using Apache 1.3 with PHP and MySQL
When using the PHP function "header" to redirect a page, I keep getting an error
Warning: Cannot add header information - headers already sent by (output started at c:\myweb\printers.php:5) in c:\myweb\printers.php on line ...
Any hints ?
Thanks
----------------------------------------------------------------------------
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
RE: [users@httpd] Allow Redirect
Posted by Werner Schalk <we...@gmx.de>.
Hello,
if you do a header redirection in PHP
you must not send any output to the client
before. Otherwise you will get the error
you have shown.
Bye,
Werner.
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: [users@httpd] Allow Redirect
Posted by John Wards <j....@sportnetwork.net>.
whats on line 5 of printers.php? as thats your problem
Also this should be on a PHP list like php-general@lists.php.net
John Wards
SportNetwork.net
----- Original Message -----
From: Luis Moreira
To: users@httpd.apache.org
Sent: Friday, August 30, 2002 11:10 AM
Subject: [users@httpd] Allow Redirect
Hi
I'm using Apache 1.3 with PHP and MySQL
When using the PHP function "header" to redirect a page, I keep getting an error
Warning: Cannot add header information - headers already sent by (output started at c:\myweb\printers.php:5) in c:\myweb\printers.php on line ...
Any hints ?
Thanks
------------------------------------------------------------------------------
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org