ID: 27091
Updated by: [EMAIL PROTECTED]
Reported By: phil at pelanne dot com
-Status: Open
+Status: Bogus
Bug Type: IIS related
Operating System: Windows Server 2003
PHP Version: 4.3.4
New Comment:
You always need to use a FULL absolute path here, like:
header("location: http://www.example.com/file2.php");
Previous Comments:
------------------------------------------------------------------------
[2004-01-29 17:36:39] phil at pelanne dot com
Description:
------------
This concerns the misbehaving header error that happens with IIS 6 (and
5, I thinks) and PHP running as a CGI, usually after some database
query (in this case on MSSQL).
I've found a way to reproduce it (and a workaround that people can take
away). Maybe there's something that can be done from the PHP side to
alleviate this? In any case, a simple code change seems get around it
(and may shed some light on the cause of this, if it is indeed a bug).
If you create the two files in the reproduce code, about half the time
you get a CGI error. If you change the header redirect line to use the
path from the site root(this example assumes you're in the root
directory of your site, so I'm just adding a slash):
header("location: file2.php"); changes to header("location:
/file2.php");
...you never get that CGI error, even though if both of the files are
in the root directory of your site, the location file2.php should be
the same as the location /file2.php
This is reproduceable with the newest stable snapshot as well (as of
1/29/04)
Hope this helps you guys (and maybe others)- thanks for a great
language!
Reproduce code:
---------------
//file1.php - replace your database host, login and password.
//Any query to any DB will do, but this Northwind database
//comes with mssql, so it's convenient
<?
$msconnect=mssql_connect("your DB host","your_login","your_password");
$msdb=mssql_select_db("Northwind",$msconnect);
$msquery = "select titleofcourtesy,firstname,lastname from employees";
$msresults= mssql_query($msquery);
header("location: file2.php");
?>
//file2.php - no actual php here
Go back to <a href="file1.php">file1.php</a>
Expected result:
----------------
One would expect to see
"Go back to file1.php"
each time you click on the file1.php link.
Actual result:
--------------
We get this sporadic error:
"CGI Error
The specified CGI application misbehaved by not returning a complete
set of HTTP headers."
...Maybe 50% of the time - until we change that path in the header to
an absolute path, then we never get the error.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27091&edit=1