Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.12.2

Bug #4024 Cannot use object of type DB_Error as array
Submitted: 2005-04-01 13:38 UTC
From: jacquem at lapp dot in2p3 dot fr Assigned: danielc
Status: Bogus Package: DB
PHP Version: 5.0.3 OS: Scientific Linux 3.0.3
Roadmaps: (Not assigned)    
Subscription  


 [2005-04-01 13:38 UTC] jacquem at lapp dot in2p3 dot fr
Description: ------------ I upgrade php from 4.1.2 to 5.0.3, I install the PEAR DB module version 1.7.4 since it is not include with php version 5. I now got a php fatal error: PHP Fatal error: Call to undefined method BB_Error::fetchRow() Reproduce code: --------------- function sess_read($key) { global $db, $SESS_LIFE; $qry = "SELECT session_vars FROM auth_session WHERE session_key = '$key'"; $qid = $db->query($qry); $value = ''; if ($row = $qid->fetchRow()) { $value = $row[session_vars]; } return $value; } Expected result: ---------------- Something working Actual result: -------------- PHP Fatal error: Call to undefined method BB_Error::fetchRow() in apache log error file

Comments

 [2005-04-01 14:59 UTC] danielc
That means your query had a problem so returned a DB_Error object instead of a DB_result object. But, you forgot to check for errors before trying to retrieve the result. Read the manual. Each example that deals with queries and results performs this check.