4

My script fails to load form_validation class.

I called it from autoload.php, controller's _construct method and the method i was intend to use (ie. login() method)

autoload.php

$autoload['libraries'] = array('database', 'Login', 'Template', 'form_validation', 'session');

controller

<?php
class Login extends CI_Controller
{
function __construct()
{
    parent::__construct();
    $this->load->model('user_model');
    $this->load->library('form_validation');
}

function logmein()
{       
    $this->load->library('form_validation');
    $this->form_validation->set_rules('userEmail', 'email', 'trim|required|valid_email|callback__check_login');
    $this->form_validation->set_rules('userPassword', 'password', 'trim|required');

please do note that, i did not try to load the class from all the three places, i tried each one solely, and the combinations, but no success. I'm running PHP Version 5.3.5 on my localhost with XAMPP on windows 7. My real server is linux so if it works well on linux, i can live with that =)

update: i have var_dumped and checked the resources, and both _user_model_ and _form_validation_ seem to work well. however, when i var_dump($this->user_model) or var_dump($this->form_validation) returns NULL.

hakre
  • 193,403
  • 52
  • 435
  • 836
Umur Kontacı
  • 35,403
  • 8
  • 73
  • 96

2 Answers2

1

All of my code was actually error-less.

However in one of my library classes, i have extended a controller class to load another library which was causing all of my errors.

I have removed it and used $CI =& get_instance(); method for loading other classes and everything works fine now.

Umur Kontacı
  • 35,403
  • 8
  • 73
  • 96
0

You have two Login classes which are being loaded simultaneously. I'll bet money that they are causing a collision. Change the name of the Library class to LoginTools or something like that, and that will help.

cwallenpoole
  • 79,954
  • 26
  • 128
  • 166
  • that was the case, however i've noticed it and removed it from the library completely since i'm writing a new one, however still no success. i also have renamed my login controller to something else, in case any conflicts, but no success. in addition, when i call the load method from the ___construct_ method, it does not throw an error which means it finds and loads it somewhere. – Umur Kontacı Jul 15 '11 at 15:13