Fatal Error Cannot Use Object Of Type Db_error As Array
Contents |
Bug Statistics Package home|Report new bug|New search|Development Roadmap Status: Open|Feedback|All|Closed Since Version cannot use object of type as array 1.9.2 Bug#4024 Cannot use object of type DB_Error as
Php Convert Object To Array
array Submitted: 2005-04-01 13:38 UTC From: jacquem at lapp dot in2p3 dot fr
Cannot Use Object Of Type Stdclass As Array
Assigned: danielc Status: Bogus Package: DB PHP Version: 5.0.3 OS: Scientific Linux 3.0.3 Roadmaps: (Not assigned) Subscription Your email: Comments Add Comment Add patch [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. PRIVACY POLICY|CREDITS Copyright © 2001-2016 The PHP Group All rights reserved. Bandwidth and hardware provided by: eUKhost
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each http://pear.php.net/bugs/4024 other. Join them; it only takes a minute: Sign up PHP Fatal Error: Cannot use object of type DataAccess as array up vote 1 down vote favorite I cannot figure out why I am getting the following error in PHP: Fatal error: Cannot use object of type DataAccess as array in /filename on line 16. Here is the http://stackoverflow.com/questions/8623065/php-fatal-error-cannot-use-object-of-type-dataaccess-as-array relevant code for the file: class StandardContext implements IStandardContext { private $dataAccess; // (CON|DE)STRUCTORS function __construct($config) { $this->dataAccess = new DataAccess($config['db']); //this is line 16 } $config refers to the following: $config = require(dirname(__FILE__)./*truncated*/.'Config.php'); Here is the relevant code for Config.php: return array( // Database connection parameters 'db' => array( 'host' => 'localhost', 'name' => 'visum', 'user' => 'root', 'password' => '' ) ); Here is the relevant code for the DataAccess object: class DataAccess { private $link; private $db; function __construct($dbConfig) { $this->link = mysql_connect( $dbConfig['host'], $dbConfig['user'], $dbConfig['password'] ) or die(mysql_error()); $this->db = $dbConfig['name']; mysql_select_db($this->db) or die(mysql_error()); } Any help would be greatly appreciate, I am fairly new to PHP and am absolutely stumped. Edit: BTW, I have included the following code to test StandardContext, which actually works (ie. it allows me to make changes to my database farther down than I have shown) class StandardContext_index_returns_defined_list implements ITest { private $dataAccess; function __construct($config) { $this->dataAccess = new DataAccess($config['db']); } php constructor data-access share|improve this question edited Dec 24 '11 at 19:41 as
looks like everything is working, except when I click the "User Panel" button on http://community.freepbx.org/t/db-error-as-array/22486 the top left of the top menu, it brings me to /recordings/index.php where I get a blank page. I looked at the apache error log to see what was causing it and this is what I got: PHP Fatal error: Cannot use object of type DB_Error as array in /var/www/html/recordings/modules/callmonitor.module cannot use on line 0 Any help in solving this would be great, Thanks,Trevor tm1000 (Andrew Nagy) 2014-06-09 15:20:44 UTC #2 uninstall endpoint manager. tlf30 2014-06-09 16:38:20 UTC #3 I have already uninstalled it, that made no difference. With uninstalling itI also had to uninstall another module that had a dependency but I cannot use object don't remember the name of it. Anyways it did not help. tm1000 (Andrew Nagy) 2014-06-09 18:25:41 UTC #4 You need to uninstall OSS Endpoint Manager. Not Endpoint. They are different. Confusing I know. The OSS one doesn't have any dependencies. then you'll need to: rm /var/www/html/recordings/modules/phonesettings.module tlf30 2014-06-10 03:00:19 UTC #5 OK, now I have uninstalled the correct one: OSS PBX End Point Manager. I still get the blank page and the same error in the apache log. tlf30 2014-06-10 03:02:02 UTC #6 OK, your fixed did work, I forgot to delete the soft link. Thank You so much! tlf30 2014-06-10 03:13:49 UTC #7 OK, it is working, except I am getting this errorCall to undefined function restapi_user_get_user_tokens() in /var/www/html/recordings/modules/callmonitor.module on line 0 On this page /recordings/index.php?m=restapi&f=display Which leaves me with a blank page. Home Categories FAQ/Guidelines Terms of Service Privacy Policy Powered by Discourse, best viewed with JavaScript enabled