|  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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: php at pilif dot ch
New email:
PHP Version: OS:


 [2004-12-22 13:44 UTC] php at pilif dot ch
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.

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...


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";
    echo "1st query succeeded\n";

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

$r = mssql_query('rollback', $link);
if ($r === false){
    echo "3rd query failed\n";
        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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-22 14:14 UTC]
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
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: Wed Jul 24 15:01:29 2024 UTC