fatal error:Call to a member function query() - 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() (/showthread.php?tid=22061) |
fatal error:Call to a member function query() - El Forum - 08-28-2009 [eluser]praveenarya[/eluser] hi all, iam new to ci iam developing a site in ci i got this error.my code is Code: if($_SERVER['REQUEST_METHOD']=="POST") Fatal error: Call to a member function query() on a non-object in D:\wamp\www\example\system\application\controllers\admin\welcome.php on line 17 can anyone help me thanks in advance fatal error:Call to a member function query() - El Forum - 08-28-2009 [eluser]Dam1an[/eluser] Have you loaded the database? Either manually, or in the autoload file? fatal error:Call to a member function query() - El Forum - 08-28-2009 [eluser]praveenarya[/eluser] ya thanks for fast reply i got it i auto loaded it instead manually but when loading error message it behaving stange mycode is Code: if($_SERVER['REQUEST_METHOD']=="POST") i got two pages one normal one and one with error message set what i did wrong please correct me thanks in advance fatal error:Call to a member function query() - El Forum - 08-28-2009 [eluser]mariek[/eluser] did you set the active record to TRUE ? in the database configuration, l. 38 : $active_record = TRUE; fatal error:Call to a member function query() - El Forum - 08-28-2009 [eluser]praveenarya[/eluser] yes,it is set to true fatal error:Call to a member function query() - El Forum - 08-28-2009 [eluser]MindFeed[/eluser] If you can post your complete model code, that might help! Thanks, Bhargav Khatana fatal error:Call to a member function query() - El Forum - 08-28-2009 [eluser]praveenarya[/eluser] sure here is my code Code: class Welcome extends Controller { and in view page i wrote Code: if(isset($errmsg)) { echo $errmsg;} fatal error:Call to a member function query() - El Forum - 08-31-2009 [eluser]MindFeed[/eluser] Can you please write following line in first place at your index() function and see if database object been created and assigned to CI or not ? Code: print "<pre>"; print_r($this);exit; you should see something like this, [that's oracle I am using, you might see relevant result] Code: [db] => CI_DB_oci8_driver Object If not can you please try loading database with the following line in your constructor. Code: $this->load->database(); Post the behavior and error if any ! Thanks, Bhargav |