php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31243 mssql_query returns false despite query succeeded (with 0 results)
Submitted: 2004-12-22 13:44 UTC Modified: 2004-12-22 14:14 UTC
From: php at pilif dot ch Assigned:
Status: Closed Package: MSSQL related
PHP Version: 5.0.3 OS: Gentoo Linux
Private report: No CVE-ID: None
 [2004-12-22 13:44 UTC] php at pilif dot ch
Description:
------------
mssql_query() returns false despite a query being successfully executed if it's a query returning empty (or none) result sets (queries like INSERT or BEGIN TRANSACTION)

Concerning my exmaple blelow: In the second two queries (where mssql_query falsly returned false), mssql_get_last_message() is empty.

Looking at the MS-SQL-Server I could confirm that the queries where executed correctly (the ones in the example do nothing, but even when INSERTing something, I'm getting the same results).

I'm quite positive that this working in PHP 5.0.2 and below.

As this is quite a simple testcase and always reproducible, I'm pretty confident to have actually hit a bug here.

Versions:
php-5.3.0 (--with-mssql)
freetds-0.62.3  (mssql support compiled in)

Looking more thorugh the bug tracker, I came across

#31195 which is the same thing for PHP 4.3. I can definitely confirm this happening with PHP5.

Thanks for listening...

Philip



Reproduce code:
---------------
<?
$link =  mssql_connect('srv', 'user', 'pass');
mssql_select_db('db', $link);
$r = mssql_query('select something', $link);
if ($r === false){
    echo "1st query failed\n";
}else{
    echo "1st query succeeded\n";
}

$r = mssql_query('begin transaction', $link);
if ($r === false){
    echo "2nd query failed\n";
}else{
        echo "2nd query succeeded\n";
}

$r = mssql_query('rollback', $link);
if ($r === false){
    echo "3rd query failed\n";
}else{
        echo "3rd query succeeded\n";
}
?>


Expected result:
----------------
1st query succeeded
2nd query succeeded
3rd query succeeded

Actual result:
--------------
1st query succeeded
2nd query failed
3rd query failed


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-22 14:14 UTC] derick@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.

Next time, search the bug database first! This has been reported atleast 10 times.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 22:01:28 2024 UTC