PHP 4.0 Bug #7548 Updated: Database links and result sets seem to not be properly returned.

From: Date: Wed, 01 Nov 2000 04:44:30 +0000
Subject: PHP 4.0 Bug #7548 Updated: Database links and result sets seem to not be properly returned.
Groups: php.dev 
Request: Send a blank email to php-dev+get-36578@lists.php.net to get a copy of this message
ID: 7548 User Update by: tonym@tk.xaxon.ne.jp Status: Open Bug Type: MySQL related Description: Database links and result sets seem to not be properly returned. Problem solved. Apparently the following syntax cannot be used: $db = mysql_pconnect("server","user","pw") || die("error"); Check for success must be as follows: $db = mysql_pconnect("server","user","pw"); if (! $db) { die("error"); } Is this correct parsing for php? Previous Comments: --------------------------------------------------------------------------- [2000-10-31 11:32:15] tonym@tk.xaxon.ne.jp Database links and result sets seem to not be properly returned. Heavily edited script: $db = mysql_pconnect("server","user","pw") || die "Couldn't connect to db!"; // or, $db = mysql_connect( ... ) // the following works: $result = mysql_list_dbs(); $x = mysql_num_rows( $result ); for ($i = 0; $i < x; $i++) { echo "table found: " . mysql_table_name($result, $i) . "<br>"; } // the following does not: $result = mysql_list_dbs( $db ); // give warning "not a valid MySQL link" $x = mysql_num_rows( $result ); // give warning "not a valid MySQL result resource" // the following works: $result = mysql_query("INSERT INTO users (id, name) VALUES (10, 'fred')"); // the following does not: $result = mysql_query("SELECT name FROM users") || die (Query failed); // die() not called while ($row = mysql_fetch_row( $result )) { // give warning "not a valid MySQL result resource" <do something> // this line is never reached } // the following also does not work: $result = mysql_query("SELECT 1 + 1 as total") || die (Query failed); // die() not called $total = mysql_fetch_row( $result ); // give warning "not a valid MySQL result resource" -------------------------------------------------- Compile options: --with-apxs=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --enable-track-vars MySQL version 3.23.27-beta --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=7548

« previous php.dev (#36578) next »