Mufleeh Posted July 8, 2011 Share Posted July 8, 2011 Hi, I am receiving the below when I'm trying to log into my system.... Fatal error: Call to a member function fetchAll() on a non-object in C:\Program Files\BitNami WAPPStack\apache2\htdocs\census\.private\permission.php on line 87 Below are the codes in the line number 86 and 87, $result = $dbh->query($query); $rows = $result->fetchAll(); Is there any error in this code or suggestions to fix this? Regards, Mufleeh Quote Link to comment https://forums.phpfreaks.com/topic/241433-fatal-error-call-to-a-member-function-fetchall-on-a-non-object/ Share on other sites More sharing options...
DavidAM Posted July 8, 2011 Share Posted July 8, 2011 That error message indicates that (in your case) $result does NOT contain an object. Since $result is set (presumably to a result object) in the previous statement, this would indicate that $dbh->query($query); failed. This would indicate that either the query failed -- you need to check the value of $query; or there is no database connection -- you need to check the code that assigns $dbh. You may also need to check the base class used to create $dbh (if it is a home-grown class). Quote Link to comment https://forums.phpfreaks.com/topic/241433-fatal-error-call-to-a-member-function-fetchall-on-a-non-object/#findComment-1240198 Share on other sites More sharing options...
Mufleeh Posted July 9, 2011 Author Share Posted July 9, 2011 Hi, I think it is being connected to the data base, because the welcome message appears with the user log in name. Next the $dbh is assigned as, $dbh = new PdoExt(); Actually the system was working perfectly before I upload few data for the database. Please check whether you can help me. Regards, Mufleeh Quote Link to comment https://forums.phpfreaks.com/topic/241433-fatal-error-call-to-a-member-function-fetchall-on-a-non-object/#findComment-1240350 Share on other sites More sharing options...
DavidAM Posted July 9, 2011 Share Posted July 9, 2011 I have provided all the help I can based on the code posted. This would indicate that either the query failed -- you need to check the value of $query; ... Did you check the $query? Is it valid? Did you run it directly? Did it work? Quote Link to comment https://forums.phpfreaks.com/topic/241433-fatal-error-call-to-a-member-function-fetchall-on-a-non-object/#findComment-1240637 Share on other sites More sharing options...
Mufleeh Posted July 10, 2011 Author Share Posted July 10, 2011 Hi DavidAM, Great it started working now! Thanks for your effort and really appreciated! Regards, Mufleeh Quote Link to comment https://forums.phpfreaks.com/topic/241433-fatal-error-call-to-a-member-function-fetchall-on-a-non-object/#findComment-1240698 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.