From:             phil at pelanne dot com
Operating system: Windows Server 2003
PHP version:      4.3.4
PHP Bug Type:     IIS related
Bug description:  Reproduceable CGI error (misbehaving header issue)

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 bug report at http://bugs.php.net/?id=27091&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27091&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27091&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27091&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27091&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27091&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27091&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27091&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27091&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27091&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27091&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27091&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27091&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27091&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27091&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27091&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27091&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27091&r=float

Reply via email to