#27091 [Bgs]: Reproduceable CGI error (misbehaving header issue)

From: Date: Thu, 29 Jan 2004 22:59:18 +0000
Subject: #27091 [Bgs]: Reproduceable CGI error (misbehaving header issue)
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-54153@lists.php.net to get a copy of this message
ID: 27091 User updated by: phil at pelanne dot com Reported By: phil at pelanne dot com Status: Bogus Bug Type: IIS related Operating System: Windows Server 2003 PHP Version: 4.3.4 New Comment: Just as followup, putting the full URI still produces this sporadic error message in this scenario. The only way it seems to work consistently is to use header("location: /file2.php") (even though now I see that it's not the OFFICIAL use of the header function). Previous Comments: ------------------------------------------------------------------------ [2004-01-29 17:40:57] derick@php.net You always need to use a FULL absolute path here, like: header("location: http://www.example.com/file2.php"); ------------------------------------------------------------------------ [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

« previous php.bugs (#54153) next »