Fatal error: Call to a member function query() on a non-object - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Fatal error: Call to a member function query() on a non-object (/showthread.php?tid=42697) Pages:
1
2
|
Fatal error: Call to a member function query() on a non-object - El Forum - 06-16-2011 [eluser]Creox[/eluser] [quote author="John_Betong_002" date="1308254970"]Have you tried using another table name? Also try http://localhost/phpmyadmin/index.php and check your database and tables. [/quote] John, The tbales are in the database that i connect to succesffully. When I exectue the following code Code: $query = $this->db->query('SELECT * FROM users WHERE UserID = '.$userID.' LIMIT 1'); I expect to get a result back. However I get the following Quote:A PHP Error was encountered i have autoloaded the database in config/autoload.php Code: $autoload['libraries'] = array('database'); What else could it be? This is driving me insane. I have just downloaded CI v2.01 at the error still occurs. Please help. Thanks Ciaran Fatal error: Call to a member function query() on a non-object - El Forum - 06-16-2011 [eluser]John_Betong_002[/eluser] It looks as though your database class is not getting loaded. Try setting your ./application/config/config.php and make sure everything is getting loaded. Code: $config['log_threshold'] = '4'; Also try this: Code: error_reporting(-1); Fatal error: Call to a member function query() on a non-object - El Forum - 06-16-2011 [eluser]Creox[/eluser] Sorry John, That didnt work. The ouput is now Code: A PHP Error was encountered Fatal error: Call to a member function query() on a non-object - El Forum - 06-16-2011 [eluser]John_Betong_002[/eluser] Did you check your error log? If there are no errors to be fixed in your error log then I would try copying the example from "Creating your own Models" and change the values where required. http://ellislab.com/codeigniter/user-guide/general/models.html Code: <?php Fatal error: Call to a member function query() on a non-object - El Forum - 06-16-2011 [eluser]InsiteFX[/eluser] Show your code were your loading your model! InsiteFX |