Welcome Guest, Not a member yet? Register   Sign In
Creating Own Library error
#1

[eluser]Murali krishna[/eluser]
Hi,

I was trying to create a new library and placed it inside application/libraries.
I have loaded the library in the autoload.php by adding the same in $autoload['libraries'].

when i try to call the function in the controller page it give me a error

Quote:A PHP Error was encountered
Severity: Notice
Message: Undefined property: Recruitment::$Empinfo
Filename: controllers/recruitment.php
Line Number: 96

Fatal error: Call to a member function setEmpEmail() on a non-object in /var/www/html/system/application/controllers/recruitment.php on line 96

I am posting my code here for you reference

Library Empinfo.php (placed in application/libraries)
Code:
class Empinfo {
    
    var $empid;
    var $empemail;
    
    function Empinfo(){
        $this->empid = "";
        $this->empemail = "";
    }
    
    function setEmpEmail($email){
        $this->empemail = $email;
    }
}

Calling it in controller page
Code:
$this->Empinfo->setEmpEmail("murali");

kindly let me know what could be the error.

Thanks and regards
Murali krishna .L
#2

[eluser]Maglok[/eluser]
It is definately not loaded. 'Call to a member function on a non-object' = It doesn't exsist. Thus something has to be wrong with the loading. Could you post your autoload? The library looks ok otherwise and should indeed be in application/libraries.
#3

[eluser]Murali krishna[/eluser]
Hi,

Here i am posting my autoload libraries code

Code:
$autoload['libraries'] = array('database', 'Session', 'empinfo');

thanks and regards
Murali krishna .L
#4

[eluser]pistolPete[/eluser]
Maybe it's a case sensitivity problem, try
Code:
$autoload['libraries'] = array('database', 'Session', 'Empinfo');
#5

[eluser]Murali krishna[/eluser]
Nope. Still it gives the same error.
#6

[eluser]pistolPete[/eluser]
Does it work using manual loading?
Code:
$this->load->library('empinfo');

You should also enable logging:
Code:
$config['log_threshold'] = 2;
#7

[eluser]Murali krishna[/eluser]
no it is not working.

this is the error message posted in the log

Quote:Undefined property: Recruitment::$Empinfo /var/www/html/system/application/controllers/recruitment.php 97
#8

[eluser]danmontgomery[/eluser]
Code:
$this->Empinfo

should be

Code:
$this->empinfo
#9

[eluser]Murali krishna[/eluser]
Sorry. same error.
#10

[eluser]InsiteFX[/eluser]
Take your library out of the autoload and try loading it in your controller

Enjoy
InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB