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

[eluser]Murali krishna[/eluser]

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)
class Empinfo {
    var $empid;
    var $empemail;
    function Empinfo(){
        $this->empid = "";
        $this->empemail = "";
    function setEmpEmail($email){
        $this->empemail = $email;

Calling it in controller page

kindly let me know what could be the error.

Thanks and regards
Murali krishna .L

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.

[eluser]Murali krishna[/eluser]

Here i am posting my autoload libraries code

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

thanks and regards
Murali krishna .L

Maybe it's a case sensitivity problem, try
$autoload['libraries'] = array('database', 'Session', 'Empinfo');

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

Does it work using manual loading?

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

[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


should be


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

Take your library out of the autoload and try loading it in your controller


Theme © iAndrew 2016 - Forum software by © MyBB