php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16411 CGI application misbehaved by not returning a complete set of
Submitted: 2002-04-03 09:46 UTC Modified: 2003-01-20 04:00 UTC
Votes:36
Avg. Score:4.8 ± 0.6
Reproduced:31 of 31 (100.0%)
Same Version:10 (32.3%)
Same OS:25 (80.6%)
From: vielina at hn dot vnn dot vn Assigned:
Status: No Feedback Package: MSSQL related
PHP Version: 4.3.0 OS: Windows 2000
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: vielina at hn dot vnn dot vn
New email:
PHP Version: OS:

 

 [2002-04-03 09:46 UTC] vielina at hn dot vnn dot vn
I have the same set of php scripts, php 4.0.6 CGI running on:
1-Windows NT 4.0 with IIS4, MySQL, MS-SQL 7; this works fine;
2-Windows 2000 server with IIS5, MySQL, MS-SQL 7; this works fine;
3-Windows 2000 advanced server with IIS5, MySQL, MS-SQL 7; this works
fine;
4-Windows 2000 advanced server with IIS5, MySQL, MS-SQL 2000; this still
works except that a curious error occurs:
Im using a lot of Header ("location: some.php") for redirections. In this
particular installation, right after the call of header function, the browser
still gets the right URI, but then it issues the following error (a copy
again here):
<message>
CGI ERROR
CGI application misbehaved by not returning a complete set of
headers.The headers that it did return are:
</message>
The funny thing was that if I refresh the page then it works just fine.

When I look back at the 4 installations, the only difference was the installation 4: MS-SQL 2000. 

I later made another test: from the installation 3, I made an upgrade of MS SQL from 7.0 to 2000. The same problem happened. 

I have tested with php 4.1.2 and 4.0.6. I had the same symptoms with both versions

Is there anything in php_mssql that does the job with MS-SQL 2000 but has some sort of side-effect that causes the above strange bug?

Would any one spend time looking into the code? It
would help us a lot. 

Thank you very much!

Loi Le V.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-02 17:53 UTC] k.schroeder@php.net
Please try it again with a right header like Location: http://www.domain.tld/some.php. Location header needs a complete absolute URI.

Regards, Kai
 [2002-06-02 22:14 UTC] vielina at hn dot vnn dot vn
I did that but it still did not work. I further tested another way: I left every thing as it was, except that I did not open an MSSQL connection. The script worked pretty well. When I changed it back, the same type of bug happened. When looking at phpinfo, even with the latest php version (4.2.1) I saw that in the MSSQL support section, the MSSQL library version was 7.0. Is this a potential source of that bug?

Loi Le V.
 [2002-06-20 15:19 UTC] mkendall25 at hotmail dot com
Same problem, slightly different case...

win2000 running php.exe 4.2.1 (and mssql 2000)

seems to happen mostly during redrects like...

header("Method: GET");
header("Status: 302 Moved");
header("Location: ". $ABSOLUTE_URL);

some claim they solved this problem by applying the workaround by microsoft (Q160422).

others say they have fixed this by blanking out the doc_root in php.ini

I still have this problem
 [2002-11-21 03:29 UTC] xd1013 at 163 dot com
I have this problem too.
 [2002-11-30 20:36 UTC] mail-php dot net at kimihia dot org dot nz
What are you doing with your database connections? Are they persistant (mssql_pconnect) or transient (mssql_connect)? Do you close your connections explicitly (mssql_close) before the end of your script?

vielina, your connections will be closed each time as you are running under the CGI.
 [2002-12-02 19:57 UTC] vielina at hn dot vnn dot vn
Database connections are all transient.

In the original code, I did not close the connections because php would do that at the end of script. But as I was in doubt, I later made a close right before calling the function header() but the same problem happened.

I also made another test: in the script I just opened and immediately right after colsed it. The same bug happened.

When I removed that tiny chunk of code, every thing worked just fine.
 [2002-12-02 19:59 UTC] vielina at hn dot vnn dot vn
Database connections are all transient.

In the original code, I did not close the connections because php would do that at the end of script. But as I was in doubt, I later made a close right before calling the function header() but the same problem happened.

I also made another test: in the script I just opened and immediately right after colsed it. The same bug happened.

When I removed that tiny chunk of code, every thing worked just fine.
 [2002-12-08 10:31 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip


 [2002-12-13 11:25 UTC] _ at mrmachine dot net
i'm also experiencing this error with win xp, mssql 2000, and php 4.3.0 rc3.

is it a problem with php, or with the mssql libraries?
 [2002-12-18 06:43 UTC] Gjalt at Liones dot nl
I have the same problem. Platform: PHP different versions, SQL Server 2000 and Windows 2000.

I see it a lot when the server is busy, or when two requests are made really fast after another.

Really need a solution for this.
 [2002-12-24 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over 2 weeks, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2002-12-25 01:53 UTC] philip@php.net
Looks like feedback exists -> open
 [2003-01-02 09:27 UTC] chr at punkten dot net
I have experienced the same bug when running Win2000 Server and MS Sql 2000. MS SQL 7 would not produce this error.
The error has been reproduced in all PHP versions I've tried up to 4.3.0.

I've tried to use delays and change preformance parameters in MSSQL, but no luck there.

A temporary solution would be to rewrite the code to use ODBC for database calls. This cannot be considered a acceptable solution, but it does work for us until this bug is corrected.
 [2003-01-06 12:02 UTC] kalowsky@php.net
What version of the MDAC are all of you using?  I've heard that the latest MDAC causes a lot of problems and that many users are downgrading to the last version.  Just wondering if this might be true or not for any of you.
 [2003-01-06 12:03 UTC] kalowsky@php.net
Updating version
 [2003-01-10 14:30 UTC] khoker at rjobrien dot com
I can also verify the problem.  MSSQL_ call followed by a header redirect produces this problem more often than it doesn't.  IIS5 with php 4.2.x.
 
Since I've been fighting this problem off and on over the last few months, I've had to switch to ODBC to meet an upcoming launch date.  However, I'll continue to follow and contribute any info I can when time allows.
 [2003-01-14 13:35 UTC] levinp at ctcgsc dot org
I too get this error message.  I am using Win 2000, IIS; and Perl 5.6.1.  My Perl script is simply:
  print "hello";
so I do not think the problem has anything to do with SQL.
 [2003-01-14 14:05 UTC] levinp at ctcgsc dot org
I just found the solution, at least for my problem.
I have a very simple Perl script, that was giving this error.
When I added to the top of the file:
  print "Content-type: text/html\n\n";
the error from IIS is gone.

I hope this helps you PHP folks.
 [2003-01-15 21:19 UTC] modea_ph at odsec dot com
I doubt that Perl solution will fix this, but I hope that this issue stays at the forefront until it can either be fixed with a PHP-side workaround or we find someone at microsoft who's friendly to our cause (not easy to do when you keep making fun of their name).  

From what I've seen in a lot of messages, mostly looking at #9852, and have seen some common threads:

Most people with this issue have SQL 2000.
Mpwti have fast servers.
Mpwti have redirects (location: or javascript's).

Some people have fixed this by changing server priority.
Sphftb implementing delays in their redirects.
Sphftb installing MDAC and security patches.
Sphftb setting IIS bandwidth limitations.
Sphftb switching away from PHP :[

It appears to a layman (who has many friends in QA roles) that we have a problem with nearly simultaneous invocations of PHP -and- MSSQL.  Early in this thread, vielina indicated that they never encountered this problem until SQL2K, so it would seem that a slave to the mssql extension dll is the suspect.

This supports most of the workaround suggestions I've seen - changing foreground/background status would impact the execution times of these scripts, slow links would prevent the redirect from turning into a GET so quickly, etc.  Some people have had luck using javascript redirects - I have seen improvement, but not elimination of the issue.  

For myself, I'm considering just doing away with my attempts to rewrite dirty, complicated URLs.  I feel for those with frameset apps, as there really is no avoiding this in such an environment.

One thought I just had, but it's a phenomenal longshot -- anyone diddle with the SQL Server Compatibility level in the SQL2K server parms?  You can set compat. to earlier versions, but I have no clue what that means.  I have never reproduced this on localhost (WinXP with PWS and MSDE SQL server)...
 [2003-01-20 04:00 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2003-02-08 20:24 UTC] xd1013 at 163 dot com
I change connection to ODBC,but this appear too.
when I press F5 button,It work well.
can u solute it? 
It's a serious problem.
now,I had to change my script from php to jsp\asp
But I really did't want to give up php.
:((( it 's hard to write english for me.
 [2003-02-08 20:26 UTC] xd1013 at 163 dot com
part for my connection class as fllow
--------------------------------------
class Connection{
	var $CID;
	var $Status=0;
	//Establish Connection to SQL Server
	function open($Host=CON_HOST,$User=CON_USER,$Pwd=CON_PWD){
	  if($this->Status==1) return $this->CID;
      $this->CID=mssql_connect($Host, $User, $Pwd); 
	  mssql_select_db(CON_DB);
	  $this->Status=1;
	  return $this->CID;
	}
	function execute($sql){
	  mssql_query($sql,$this->CID);
	  return mssql_rows_affected($this->CID);
	} 
	//Close Connection
	function close(){
	  return mssql_close($this->CID);
	} 

} // end class
 [2003-05-12 07:23 UTC] pedro at fundacaounimed dot com dot br
I think I find the solution for this problem...
Just put this line "cgi.rfc2616_headers = 1" on php.ini.
Please, send us a message if it works. I had this problem during much time and looking for solution, I saw that many others have it too.

PS.: sorry if there is some english error.
 [2004-01-15 06:58 UTC] abanet at pas dot ucm dot es
After a lot of time trying redirection with header
and always getting "CGI application misbehaved by not returning a complete set of ..." error after an SQL 2000 insert instruction I tried this with success:

print "<html><head><META HTTP-EQUIV='Refresh' CONTENT='0;URL=url'></head></html>";
 [2004-01-22 11:21 UTC] silvercrow13 at hotmail dot com
I've got the same problem and I can't find a solution. I'm using 2 computers as I do some work at work and at home. My configs are pretty much the same in both computers. Both work under Win Xp SP1 Pro, IIS 5.1, PHP 4.3.4 and MySql 4.0.
This only happens at work, at home it works just fine, never had any problem. I'm scared I will have to reinstall my system anytime for some other reason and see this issue bothering me at home too.

Some say it is CPU speed related but I don't know. My home PC is P4 with HT and at work I use an AMD Duron based system. Doesn't seem that relevant.

Most of the comments refer to a MSSQL issue but I use Mysql and I have this same problem too. I read somewhere it's related to the use of frames. I thought so but when using header redirection I encounter the same annoying message.

I even tought of installing Apache instead of IIS but the MS web server seems a lot less scary, I'm just a newbie. I can't find a reason for this to happen only at my work PC. Please help
 [2004-02-16 19:52 UTC] atpires at terra dot com dot br
Using FastCGI solve this problem.
 [2004-12-18 00:23 UTC] win at ridingacrossusa dot com
I am having the same porblem, and I would like to know that anyone has a solution for this problem.
 [2005-08-08 13:10 UTC] richard at eliteinternet dot net
i experience this error only when using database connectivity just before  a redirect. With alot of reading and research that contradicts, i found that if you use 

sleep(1); //make script wait one second

just before headers being send this reduces drastically the chances of getting this error, not a 100% fix but i would estimate about a 95%.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC