CodeIgniter Forums
Fatal error: Call to a member function on a non-object -- ** IMPORTANT SOLUTION - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forum-22.html)
+--- Thread: Fatal error: Call to a member function on a non-object -- ** IMPORTANT SOLUTION (/thread-31144.html)



Fatal error: Call to a member function on a non-object -- ** IMPORTANT SOLUTION - El Forum - 06-08-2010

[eluser]ACEFX[/eluser]
Hi

I thought i should post this as it will help alot, i have an application built on CI running perfectly on my Ubuntu machine @ home but when uploaded to my server it fails and gives the error:

Fatal error: Call to a member function on a non-object...

I tried to solve it and kept getting thesame error, finally i realized that the default version of PHP is 4 so using :
Code:
function __construct(){
        parent::Controller();
}

makes it fail for loading default model.
So incase you are still on PHP4 you might want to use

Code:
function Classname(){
        parent::Controller();
}

so you can load any model at runtime.

Thanks


Fatal error: Call to a member function on a non-object -- ** IMPORTANT SOLUTION - El Forum - 06-08-2010

[eluser]n0xie[/eluser]
Seems pretty obvious to me that if you are running PHP4 you should use PHP4 constructors...