[PHP-DB] mssql_query returns a boolean false instead an empty recordset when the 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 smime.p7s Description: S/MIME Cryptographic Signature
[PHP-DB] transactions
hi, i have a problem with mysql transactions and php: i want to do a transaction through more than one php scripts. i think, if one script ends and links to another, the database connection ends and the transaction rolles back. how can i continue one transaction through more than one script? any ideas? please help, cheers, martin -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] mssql_query returns a boolean false instead an empty recordset whenthe query doesn't match any record
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 [EMAIL PROTECTED] To: php-db@lists.php.net 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-DB] Specific order by MySQL statement
Hi I am trying to get results from a MySQL query in a specific order, just using ASC or DESC will not work. For Example I have a field that can contain 4 possible values: 'Current', 'Completed','Withdrawn' or 'Transferred', I would like to order the results specifically like: Current Completed Withdrawn Transferred Is there any way i can do this using MySQL? Any help will be much appreciated. Thanks, Ade -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Specific order by MySQL statement
One possibility is to use codes for this filed, such as: 10 for Current; 20 for Completed; 30 for Withdrawn; 40 for Transferred. a.s.o. If you will discover other states of the field you can insert them apropriatelly (if you want Canceled state to be inserted and to be displayed last put the code 45 for it). Best regards, Aurel On Mon, 2005-11-07 at 11:47 +, Adrian Bruce wrote: Hi I am trying to get results from a MySQL query in a specific order, just using ASC or DESC will not work. For Example I have a field that can contain 4 possible values: 'Current', 'Completed','Withdrawn' or 'Transferred', I would like to order the results specifically like: Current Completed Withdrawn Transferred Is there any way i can do this using MySQL? Any help will be much appreciated. Thanks, Ade
Re: [PHP-DB] mssql_query returns a boolean false instead an empty recordset whenthe query doesn't match any record
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 [EMAIL PROTECTED] To: Pablo F. DÃaz Anzalone [EMAIL PROTECTED],php-db@lists.php.net 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 [EMAIL PROTECTED] To: php-db@lists.php.net 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
RE: [PHP-DB] transactions
I don't think you can. Once the script finishes the connections are closed and the transactions completed. What are you trying to do where you need to have the transaction across multiple pages? Perhaps, if you are gathering the data across the pages, you could use a session to store the data until you have all the elements, then start the transaction, so your inserts and commit... Bastien From: martin lutsch [EMAIL PROTECTED] To: php-db@lists.php.net Subject: [PHP-DB] transactions Date: Mon, 07 Nov 2005 11:18:53 +0100 hi, i have a problem with mysql transactions and php: i want to do a transaction through more than one php scripts. i think, if one script ends and links to another, the database connection ends and the transaction rolles back. how can i continue one transaction through more than one script? any ideas? please help, cheers, martin -- 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