Call to a member function ... on a non-object |
[eluser]BigBonsai[/eluser]
Hello, I have been struggling to get my bearings on CI now for a few days. Things have gone fairly well. I have overcome the dust on the user guide (some outdated stuff in there) and now I am thoroughly stuck. After reading this forum for two hours I still cannot get anywhere, although this problem has been discussed before. I guess my understanding of OOP is not good enough. Well, let's see. This is my error message: Code: Fatal error: Call to a member function login() on a non-object in [...]\application\controllers\pages.php on line 46 Ok. So here is "pages.php": Code: <?php The problem is this line: Code: $this->login_model->login(); Code: <?php As you can see (for whoever knows it), the login function is copied from the Simplelogin library, but ultimately I suspect it doesn't matter what it says in there, since it is not accessed in the first place. The database connection is not included, because I have this line in the autoconfig.php: Code: $autoload['libraries'] = array('database', 'session'); In my humble understanding, this should take care of the database connection. What am I overlooking/messing up for getting the above mentioned error? Thanks a bundle in advance! ![]() BiB
[eluser]Rodrigo Alexandre[/eluser]
try class login_model or $this->Login_model->login(); using the first letter capitalized
[eluser]BigBonsai[/eluser]
[quote author="Samus" date="1334416811"]Did you load the model?[/quote] No... *argh* Stupid me!!! And for that 3 hours... So if another n00b like me ever runs into this: In my case the simple solution is this line Code: $this->load->model('login_model'); ![]() BiB
[eluser]chochoro[/eluser]
Will you help me? This is my problems: A PHP Error was encountered Severity: Notice Message: Undefined property: Site::$session Filename: controllers/site.php Line Number: 23 Fatal error: Call to a member function userdata() on a non-object in C:\Program Files\EasyPHP-12.1\www\Ang_Hirap_Haha\application\controllers\site.php on line 23 Here are my codes: admin.php Code: <?php site.php Code: <?php Code: <?php Code: $config['encryption_key'] = 'userdata';
[eluser]GrahamDj28[/eluser]
try auto loading your libraries with all lowercase chars.
[eluser]chochoro[/eluser]
cases don't matter sir. i already tried that one. tsk. i wanna finish our project as fast as i can before the semester ends.
[eluser]GrahamDj28[/eluser]
I see you are not calling the constructor of CI_controller Change the constructor from Code: function __construct() To this Code: function __construct() By not calling the parent constructor the CI super object is not available
[eluser]soluicius[/eluser]
Hello, I followed this tutorial( https://tutsplus.com/course/codeigniter-best-practices/ - 04-Using Third Party Libraries) but i'm stuck while securing the pages. I think spark doesn't load ion_auth model I get this error: Code: A PHP Error was encountered Here is my controller: 1) user.php Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 2) welcome.php Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); and in autoload.php i have: Code: $autoload['sparks'] = array('ion_auth'); |
Welcome Guest, Not a member yet? Register Sign In |