【问题标题】:An Error Was Encountered. Unable to load the requested class: database遇到错误。无法加载请求的类:数据库
【发布时间】:2014-09-30 17:42:23
【问题描述】:

我在 application/controller/ 目录中名为 logincontroller.php 的登录控制器是:

<?php

class LoginController extends CI_Controller {
public function __construct() {
    parent::__construct();
    $this->load->model('LoginModel');
    $this->load->library('form_validation');
    $this->load->database();
} 


public function index(){
$this ->load ->view('login_view');
}

public function checklogin(){
    $this->form_validation-> set_rules('email', 'email', 'required|valid_email');
    $this->form_validation-> set_rules('password', 'password', 'required|callback_verifyUser');

    if($this -> form_validation ->run() == false){

        $this->load->view('login_view');
    }else{
             redirect('dashcontroller/index');

    }
}


public function verifyUser(){

    $email = $this -> input -> post('email');
    $password= $this -> input ->post('password');

    $this->load->model ('LoginModel');

    if($this->LoginModel->login($email, $password)) {
        return true;
    }else{
        $this ->form_validation->set_message('verifyUser','wrong email or password');
        return false;
}

}

} ?>

为什么会出现错误?

我也将数据库的 autoload.php 更改为 $autoload['libraries'] = array('database');

我收到错误:无法加载请求的类:数据库

【问题讨论】:

    标签: php codeigniter


    【解决方案1】:

    这个错误可能是由于某些原因造成的。

    1)Somehow the filename of the library managed to chance causing CodeIgniter to be unable to find the file

    2)Perhaps the file doesn't exist on the server and once again, CodeIgniter is unable to find it.

    3)The filename may be different to that you are referring to in your code.

    查看source

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-31
      • 1970-01-01
      • 2018-10-01
      • 1970-01-01
      • 2013-05-22
      • 2015-08-09
      • 2019-06-01
      • 2020-11-14
      相关资源
      最近更新 更多