CodeIgniter Forums
Call to a member function Create() on a non-object - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: Call to a member function Create() on a non-object (/thread-19019.html)



Call to a member function Create() on a non-object - El Forum - 05-25-2009

[eluser]Ludatha[/eluser]
Hey I am new to CI and I want to change my current site to use it.
I have downloaded the library SimpleLoginSecure and cannot seem to get it working.

This is my complete code.
Code:
<?php
class Profile extends Controller {    
    function index()
    {
        $this->load->library('SimpleLoginSecure');
        $this->SimpleLoginSecure->Create('usernamehere', 'passwordhere');
    }
}
?>

Errors:

A PHP Error was encountered
Severity: Notice
Message: Undefined property: Profile::$SimpleLoginSecure
Filename: controllers/profile.php
Line Number: 6

Fatal error: Call to a member function Create() on a non-object in D:\wamp3\www\php\system\application\controllers\profile.php on line 6

When things go wrong it is generally something obvious so I apologise if it is.

- Adam


Call to a member function Create() on a non-object - El Forum - 05-25-2009

[eluser]Dam1an[/eluser]
Is the Simpleloginsecure file in the libraries folder? Is the filename got the first letter in upper case?

Could try manually incluing it and creating the object yourself instead of using the loader, see if that works


Call to a member function Create() on a non-object - El Forum - 05-25-2009

[eluser]Ludatha[/eluser]
Thanks for the reply, I tried this code:

Code:
<?php
class Profile extends Controller {    
    function index()
    {
        include('D:\wamp3\www\php\system\application\libraries\SimpleLoginSecure.php');
        $cheese = new SimpleLoginSecure;
        $cheese->SimpleLoginSecure->Create('usernamehere', 'passwordhere');
    }
}
?>

But I get exactly the same error except the line number is 7

Message: Undefined property: SimpleLoginSecure::$SimpleLoginSecure


Call to a member function Create() on a non-object - El Forum - 05-25-2009

[eluser]Dam1an[/eluser]
it should be
Code:
$cheese = new SimpleLoginSecure();
$cheese->create(.....



Call to a member function Create() on a non-object - El Forum - 05-25-2009

[eluser]Ludatha[/eluser]
Oh yeah, Shows how much I remember things =)

Changed the code, but a different error this time. I've had this before.
Code:
<?php
class Profile extends Controller {    
    function index()
    {
        include('D:\wamp3\www\php\system\application\libraries\SimpleLoginSecure.php');
        $cheese = new SimpleLoginSecure();
        $cheese->Create('usernamehere', 'passwordhere');
    }
}
?>

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Profile::$db

Filename: libraries/SimpleLoginSecure.php

Line Number: 61


Fatal error: Call to a member function where() on a non-object in D:\wamp3\www\php\system\application\libraries\SimpleLoginSecure.php on line 61


Call to a member function Create() on a non-object - El Forum - 05-25-2009

[eluser]Dam1an[/eluser]
I'm guessing you havn't loaded the database class? I'd recommend adding it to autoload in the config directory


Call to a member function Create() on a non-object - El Forum - 05-25-2009

[eluser]Ludatha[/eluser]
Oh, it works now Smile

Thanks for your help!


Call to a member function Create() on a non-object - El Forum - 05-25-2009

[eluser]Dam1an[/eluser]
The Damianmeister does it again Smile
Is it working through $this or just by creating an object?


Call to a member function Create() on a non-object - El Forum - 05-25-2009

[eluser]Ludatha[/eluser]
Oh, I just changed it back to $this

and I am back to square one... Tongue

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Profile::$SimpleLoginSecure

Filename: controllers/profile.php

Line Number: 6


Fatal error: Call to a member function Create() on a non-object in D:\wamp3\www\php\system\application\controllers\profile.php on line 6


Call to a member function Create() on a non-object - El Forum - 05-25-2009

[eluser]Dam1an[/eluser]
Hmm, the only thing I can think of, is you have 2 variables with the same name 9although its unlikely with something like SimpleLoginSecure) and the second one is overwriting yours, and doesn't have the create method