CodeIgniter Forums
Mind Bending Error - 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: Mind Bending Error (/showthread.php?tid=19060)



Mind Bending Error - El Forum - 05-26-2009

[eluser]JasonS[/eluser]
This should be really simple but I cannot work it out.

This is my error.

Quote:Fatal error: Call to a member function update() on a non-object in /Applications/XAMPP/xamppfiles/htdocs/wpp/admin/system/application/controllers/pages.php on line 65

This is my code.

Code:
65. $this->db->update($this->jdb->table, $this->db, "id='$id'");

The database library is loaded, I can add pages to my site, I can list pages. For some reason, when I run this update function I get the error. Its pretty late where I am, maybe my brain is a bit fried but I have been staring at this for ages and cannot see what is wrong.


Mind Bending Error - El Forum - 05-26-2009

[eluser]Colin Williams[/eluser]
The database is available in the other contexts, but is it for some reason unavailable in this context?

It is odd to me that you have $this->db as a second parameter. There is a good chance you are mistakenly overwriting the $this->db reference to the Database class with your own data.


Mind Bending Error - El Forum - 05-26-2009

[eluser]Dam1an[/eluser]
If you have a constructor, are you calling the parent one? If not, it won't have any idea what $this->db is


Mind Bending Error - El Forum - 05-26-2009

[eluser]JasonS[/eluser]
*sigh*

Thanks a lot guys. Completely overlooked the fact that the db variable would overwrite the function. I needed the db variable to be availible to whole class and thus just added a $this-> in front of it.. Duh Smile