mssql_query returns a boolean false instead an empty recordset when

mssql_query returns a boolean false instead an empty recordset when

am 07.11.2005 11:38:11 von unknown

--------------ms080005020705050001080306
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

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


--------------ms080005020705050001080306
Content-Type: application/x-pkcs7-signature; name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7s"
Content-Description: S/MIME Cryptographic Signature

MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEH AQAAoIIWcjCC
BcAwggSooAMCAQICAQUwDQYJKoZIhvcNAQEFBQAwfzELMAkGA1UEBhMCRVUx JzAlBgNVBAoT
HkFDIENhbWVyZmlybWEgU0EgQ0lGIEE4Mjc0MzI4NzEjMCEGA1UECxMaaHR0 cDovL3d3dy5j
aGFtYmVyc2lnbi5vcmcxIjAgBgNVBAMTGUNoYW1iZXJzIG9mIENvbW1lcmNl IFJvb3QwHhcN
MDQwMjA5MTU0MjQ3WhcNMzQwM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W1lcmFs
ZXMCAhMTMIH6BgsqhkiG9w0BCRACCzGB6qCB5zCB4DELMAkGA1UEBhMCRVMx LjAsBgkqhkiG
9w0BCQEWH2FjX2NhbWVyZmlybWFfY2NAY2FtZXJmaXJtYS5jb20xQzBBBgNV BAcTOk1hZHJp
ZCAoc2VlIGN1cnJlbnQgYWRkcmVzcyBhdCB3d3cuY2FtZXJmaXJtYS5jb20v YWRkcmVzcykx
EjAQBgNVBAUTCUE4Mjc0MzI4NzEZMBcGA1UEChMQQUMgQ2FtZXJmaXJtYSBT QTEtMCsGA1UE
AxMkQUMgQ2FtZXJmaXJtYSBDZXJ0aWZpY2Fkb3MgQ2FtZXJhbGVzAgITEzAN BgkqhkiG9w0B
AQEFAASBgHt8SGSzGCEnZ/xVPh0WtT5tvRJ/isUoXa4jvlDcxpPk5lrOozZT NvXTf2vSIrT3
D8upV+l3Enw8gOJibGwc6A7Pc+KHTT9apK44Eu0t6NMmAcCFym4ZuTclY183 UWiMPZ3IQ+zD
mmXJVUDyWlgIN/Lpyb8nLbiT3ae4qpgop6iJAAAAAAAA
--------------ms080005020705050001080306--

Re: mssql_query returns a boolean false instead an empty recordset whenthe query doesn"t match any r

am 07.11.2005 12:07:09 von ziv gabel

you can try this

while ($row = @mssql_fetch_array($result, MSSQL_ASSOC))
> {
if(!$row) {
continue;
}
else {
> //process each registry from the query
}
> }

Best Regards
Ziv Gabel
Pineapp Support
----- Original Message -----
From: ""Pablo F. Díaz Anzalone""
To:
Sent: Monday, November 07, 2005 12:38 PM
Subject: [PHP-DB] mssql_query returns a boolean false instead an empty
recordset whenthe query doesn't match any record


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




************************************************************ ************************
This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses.
************************************************************ ************************


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: mssql_query returns a boolean false instead an empty recordset

am 07.11.2005 16:33:33 von Bastien Koert

He needs to check whether the query worked before he attempts to access the
data

$result = mssql_query($query);
if (mssql_errno) != 0)
{
echo "error in query :". mssql_error();
die();
}


Bastien

>From: "Ziv Gabel"
>To: "Pablo F. Díaz Anzalone"
>,
>Subject: Re: [PHP-DB] mssql_query returns a boolean false instead an empty
>recordset whenthe query doesn't match any record
>Date: Mon, 7 Nov 2005 13:07:09 +0200
>
>you can try this
>
> while ($row = @mssql_fetch_array($result, MSSQL_ASSOC))
>> {
> if(!$row) {
> continue;
> }
> else {
>> //process each registry from the query
> }
>> }
>
>Best Regards
>Ziv Gabel
>Pineapp Support
>----- Original Message ----- From: ""Pablo F. Díaz Anzalone""
>
>To:
>Sent: Monday, November 07, 2005 12:38 PM
>Subject: [PHP-DB] mssql_query returns a boolean false instead an empty
>recordset whenthe query doesn't match any record
>
>
>>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
>>
>>
>
>
>
>
>*********************************************************** *************************
>This footnote confirms that this email message has been scanned by
>PineApp Mail-SeCure for the presence of malicious code, vandals & computer
>viruses.
>*********************************************************** *************************
>
>
>--
>PHP Database Mailing List (http://www.php.net/)
>To unsubscribe, visit: http://www.php.net/unsub.php
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php