Problems with "no database selected" error with DB.php
| From: | Charlene | Date: | Tue, 27 Dec 2005 01:57:16 +0000 |
| Subject: | Problems with "no database selected" error with DB.php | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-40926@lists.php.net to get a copy of this message | ||
I am using a class to do a query. It works fine the first time, but hte next time, I get the "no database selected error. When I use this line:
print_r($this->dbh);
The following is displayed:
db_mysql Object ( [phptype] => mysql [dbsyntax] => mysql [features] => Array ( [limit] => alter [new_link] => 4.2.0 [numrows] => 1 [pconnect] => 1 [prepare] => [ssl] => [transactions] => 1 ) [errorcode_map] => Array ( [1004] => -15 [1005] => -15 [1006] => -15 [1007] => -5 [1008] => -17 [1022] => -5 [1044] => -26 [1046] => -14 [1048] => -3 [1049] => -27 [1050] => -5 [1051] => -18 [1054] => -19 [1061] => -5 [1062] => -5 [1064] => -2 [1091] => -4 [1100] => -21 [1136] => -22 [1142] => -26 [1146] => -18 [1216] => -3 [1217] => -3 ) [connection] => Resource id #21 [dsn] => Array ( [phptype] => mysql [dbsyntax] => mysql [username] => username [password] => password [protocol] => [hostspec] => localhost [port] => [socket] => [database] => database ) [autocommit] => 1 [transaction_opcount] => 0 [_db] => database [_debug] => [_default_error_mode] => [_default_error_options] => [_default_error_handler] => [_error_class] => DB_Error [_expected_errors] => Array ( ) [fetchmode] => 3 [fetchmode_object_class] => stdClass [was_connected] => [last_query] => [options] => Array ( [result_buffering] => 500 [persistent] => [ssl] => [debug] => 0 [seqname_format] => %s_seq [autofree] => [portability] => 0 [optimize] => performance ) [last_parameters] => Array ( ) [prepare_tokens] => Array ( ) [prepare_types] => Array ( ) [prepared_queries] => Array ( ) )
It looks like the database is selected. This is my query line:
$result = $this->dbh->query($statement);What am I doing anything wrong? Charlene