am using ci 2.1.4 to create a simple crud application being new to ci and am having this error:'Unable to load the requested class: validation'
here is my controller code:

class Person extends CI_Controller{

    //num of records per page
    private $limit = 10;

    public function __construct(){
        //load library
        //load helper
        //load model

    function index($offset = 0){
        $uri_segment = 3;
        $offset = $this->uri->segment(uri_segment);
        //load data
        $person = $this->person_model->get_paged_list($this->limit, $offset)->result();
        //generate pagination
        $config['base_url'] = site_url('person/index/');
        $config['total_rows'] = $this->person_model->count-all();
        $config['per_page'] = $this->limit;
        $config['uri_segment'] = $uri_segment;
        $data['pagination'] = $this->pagination->create_links();
        //generate table data
        $this->table->set_empty(" ");
        $this->table->set_heading('No', 'Name', 'Date of Birth (dd-mm-yyyy)', 'Sex', 'Actions');
        $i = 0 + $offset;
        foreach ($persons as $person){
            $this->table->add_row(++$i, $person->name, strtoupper($person->sex)=='M'? 'Male':'Female', date('d-m-Y', strtotime($person->dob)),
            anchor('person/view/'.$person->id,'view',array('class'=>'view')).' '.   
            anchor('person/update/'.$person->id,'update',array('class'=>'update')).' '.
            anchor('person/delete/'.$person->id,'delete',array('class'=>'delete','onclick'=>"return confirm('Are you sure you want to delete this person?')"))
        $data['table'] = $this->table->generate();
        //load view
        $this->load->view('person_list', $data);

Any idea what might be wrong?

Recommended Answers

All 4 Replies


The error says that library file is missing. I think 'validation' is not CI core library. I think you need 'form_validation'. So please try with 'form_validation' instead of 'validation'.

Please check and let me know.

I totally agree with Ajay, the CI library for validating form is called form_validation.


After changing to 'form_validation' is it working?

Please let me know.

This has nothing to do with the controller code but the configurations in autoload.php. Go to the config folder and open autoload.php go the line where its written $autoload['libraries'] = array('.... then remove validation from the list and it work

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.