![]() |
Still trying to link database with website - 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: Still trying to link database with website (/showthread.php?tid=32901) |
Still trying to link database with website - El Forum - 08-09-2010 [eluser]Unknown[/eluser] Thanks for your effort to help me connect my database with my site.putting the code: $this->load->database('default'); in my controller after the constructor has still not helped.The same thing for the autoload configuration.Please permit me ask you this question. Since the error message is about a "Call to a member function on a non-object" and is in the file which displays my page(that is view,and the error line number is pointing to the same file),does that not show that something needs to be done about: $query = $this->db->query('SELECT name, title, email FROM my_table'); (which is the first line of the php code sending request to the database) Please I seriously need your help Still trying to link database with website - El Forum - 08-09-2010 [eluser]mddd[/eluser] On that line there is only one "member function of an object" and that is $this->db->query. You say you are using that line in your VIEW? Then that is the problem. $this->db is not available in the view. You should use it in the controller or the model!! Get your db information there, and send the RESULT to the view to be displayed! Still trying to link database with website - El Forum - 08-09-2010 [eluser]Georgi Budinov[/eluser] mddd, you are not right. Using $this->db is OK from the view although it is not a good practice, of course. ndijones, I think that you should provide the code in order someone to solve your problem! |