php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31587 return value of mssql_query changed in 4.3.10, no longer returns accurate rslt.
Submitted: 2005-01-17 21:27 UTC Modified: 2005-01-17 23:42 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: php at yvanrodrigues dot com Assigned:
Status: Closed Package: MSSQL related
PHP Version: 4.3.10 OS: Windows 2000/IIS 5.0/PHP 4.3.11
Private report: No CVE-ID: None
 [2005-01-17 21:27 UTC] php at yvanrodrigues dot com
Description:
------------
Previous to 4.3.10, mssql_query returned the following:
=== a valid result set OR
=== true if successful but no result set OR
=== false if an error occurred

Therefore if one wanted to check for an error one would use:
if(mssql_query === false) { echo 'yikes!'; }

Since 4.3.10, when using mssql_query to execute an INSERT query, a result of false is returned even if the row was successfully inserted.

Reproduce code:
---------------
$query = "INSERT INTO DOGBERT (CATBERT) VALUES ('DILBERT')";
$rs = mssql_query($query);
if($rs === false) {
   echo 'This should only print when there is an error';
}


Expected result:
----------------
$rs should only evaluate === false when there is an error (according to the docs)

Actual result:
--------------
$rs always evaluates === false on INSERT

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-17 22:11 UTC] php at yvanrodrigues dot com
obviously that should read:
if(mssql_query($sql) === false) { echo 'yikes!'; }
 [2005-01-17 22:57 UTC] tony2001@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.
 [2005-01-17 23:42 UTC] php at yvanrodrigues dot com
I will update my unix servers. How often are the Windows binaries updated? Thanks for the quick response.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sun Oct 02 04:05:53 2022 UTC