[freetds] mssql_query returns a boolean false instead an empty recordset when the query doesn't match any record

"Pablo F. Díaz Anzalone" pablo.anzalone at iso.bbe.es
Mon Nov 7 05:16:01 EST 2005


Hi all,

    I'm moving my intranet pages from one server to a new one. In the 
first server everything works ok but in the new one we are having 
problems because every time that we are expecting a recordset and it 
should be empty because the query doesn't match any record it is return 
a boolean valued to false and we get this error when we call 
mssql_fetch_row:
Warning: mssql_fetch_array(): supplied argument is not a valid MS 
SQL-result resource

    The code we are using is something like this:

    $db = @mssql_connect("SERVER","USER","PASS") or die("I can't connect 
to server");
    mssql_select_db("DATABASE");
    $query = "SELECT * FROM table WHERE false";
    $result = mssql_query($query);
    while ($row = mssql_fetch_array($result, MSSQL_ASSOC))
    {
       //process each registry from the query
    }

Everything works fine when the query match at least a record but 
mssql_query doesn't return a recordset when it should return an empty one.

We have a debian stable installation with php version 4.3.10-16 and 
freetds-dev 0.63-2.  To obtain  freetds  module  we configured and 
compiled  php with  "../configure --with-mssql=shared" and "copied with 
cp modules/mssql.so /usr/lib/php4/20020429/". I know it could be a bit 
strange doing things in this way but it was the one I got to have a 
stable debian and apache and php and freetds installed with packages.

I hope there is someone who could help me.

Pablo

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 6891 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.ibiblio.org/pipermail/freetds/attachments/20051107/4d991519/smime.bin


More information about the FreeTDS mailing list