RE: [PHP-DEV] PHP 4.0 Bug #7141: pg_exec returns true even though it failed

From: Date: Wed, 11 Oct 2000 21:35:41 +0000
Subject: RE: [PHP-DEV] PHP 4.0 Bug #7141: pg_exec returns true even though it failed
Groups: php.dev 
Request: Send a blank email to php-dev+get-34716@lists.php.net to get a copy of this message
It did succeed, it just happened to return 0 rows. Use pg_numrows to see how many rows were returned. -----Original Message----- From: dbi@xmission.com [mailto:dbi@xmission.com] Sent: Wednesday, October 11, 2000 5:27 PM To: php-dev@lists.php.net Subject: [PHP-DEV] PHP 4.0 Bug #7141: pg_exec returns true even though it failed From: dbi@xmission.com Operating system: Redhat Linux 6.2 PHP version: 4.0.2 PHP Bug Type: PostgreSQL related Bug description: pg_exec returns true even though it failed When I execute the following code segment with the $EmailAddress and $Password variables set to values that exist in the PostgreSQL 6.5.3 table, everything works fine. When I execute it with values that are NOT in the table, pg_exec still returns a "true" value even though the SELECT statement never found any matching rows. (This is contrary to what the documentation implies when it tests for !$result.) The actual value of the $query variable, even when the query sent by the pg_exec function fails, is "Resource id #2". Because it's not falst, there's no way to test whether the query succeeded. So when the program goes on to execute the pg_fetch_array function, the $query variable points to nothing and the program dies with an error message. ------------------------------- <?php // -- This module checks a username and password to see who the user is.) $db = pg_connect("", "", "", "", "tracker"); if ($db) { $SQLQuery = "SELECT userid FROM users WHERE username = '" . $EmailAddress . "' AND password = '" . $Password . "';"; $query = pg_exec($db, $SQLQuery); if ($query) { $row = 0; if ($data = pg_fetch_array($query, $row)) { // Etc... -- Edit Bug report at: http://bugs.php.net/?id=7141&edit=1 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe@lists.php.net For additional commands, e-mail: php-dev-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.dev (#34716) next »