Welcome Guest, Not a member yet? Register   Sign In
[Solved] - Problem in loading Validation Library

Hi all,

I have presented my code below which causes error on my server. But i have tested the same code in some other server, it works fine.

So may i know what causes error in the server. Do i needs to check any php.ini settings ?

class Sample extends Controller
    function Sample()

    function index()
        //Load the required libraries.
        //Set the validation rules

    function _loginFrmRules()
        $rules['admin_name']        = 'trim|required';


        $fields['admin_name']        = $this->lang->line('login_username');



A PHP Error was encountered

Severity: Notice

Message: Undefined property: Sample::$validation

Filename: admin/sample.php

Line Number: 23

Can any one guide me on how to fix this issue. Please help me.

load library fo validation in constructor not in index function

If i load the validation library in the constructor then it's working fine. But i needs to know why it has to be loaded in the constructor as i does not need the validation library in all the functions of the sample class.

The same problem occurs while loading some models.

Also we have completed project in the way i have given. So any please provide any alternative solution for the problem.

for this purpose you have load library in that paricular function than it will work.
reason have mentioned in user guide in codeignitor.
hope you got

What is line 33? I just tried your code but without the fields part and it worked.

for loading modle you are facing same problem. try to solve it yourself

Prasanna, check your system/logs directory, maybe the validation library is being loaded automatically by another library that you specified in autoload.php ie: Session class with sess_encrypt_cookie set to TRUE (This led me once to a bug when the user was idle for a time longer than sess_expiration)

Look for this line in your logs
Validation Class Initialized

If that's your case, check which library is loading it and under which circumstances.

I have updated my post as the line number i have specified is wrong. Now it's perfect.

Couldn't you just add a comment this line is the problem Smile So it's the line were you add the field. Are you sure the login_username is loaded in the language library? you can check it using

For me this solution got worked

Use the following line in the .htaccess file.

php_flag zend.ze1_compatibility_mode off

For more info have a look @ this


Theme © iAndrew 2016 - Forum software by © MyBB