CodeIgniter Forums
Trouble calling Library Function? - 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: Trouble calling Library Function? (/showthread.php?tid=9844)



Trouble calling Library Function? - El Forum - 07-10-2008

[eluser]JasonS[/eluser]
I am reorganising my application and I am having some trouble calling a Library function. The library class is being autoloaded. This is working as this function works when called from a template file.

However when I try to call it from my controller I get a PHP error.

Error:
Quote:A PHP Error was encountered

Severity: Notice

Message: Undefined property: Reception::$User

Filename: controllers/reception.php

Line Number: 17

Fatal error: Call to a member function userIsLoggedIn() on a non-object in /Applications/xampp/xamppfiles/htdocs/JasonHome/system/application/controllers/reception.php on line 17

Autoload:
Code:
$autoload['libraries'] = array('database', 'session', 'setsession', 'user');

Function I am trying to call
Code:
class User
{
    private $CI;
    
    public function __construct()
    {
        $this->CI =& get_instance();
    }
    
    public function userIsLoggedIn($id = NULL)
    {
        $id = idIsUserId($id);
        
        if ($id > 0)
        {
            return true;
        }
    }
}

The line calling it
Code:
class Reception extends Controller
{

    function __construct()
    {
        parent::Controller();
    }
    
    function Register()
    {
        // Load Model
        $this->load->model('reception/registration');
        // Redirect Registered Users
        if ($this->User->userIsLoggedIn()) // <<---- Error pops up here
        {
            header('location: '.base());
        }

Does anyone know what is going on? Help resolving this matter would be greatly appeciated.


Trouble calling Library Function? - El Forum - 07-10-2008

[eluser]xwero[/eluser]
have you tried with a lowercase u?


Trouble calling Library Function? - El Forum - 07-10-2008

[eluser]JasonS[/eluser]
Thanks a lot. I was unaware that calling libraries was sensitive.