codeigniter遇到未捕获的异常类型:RuntimeException在Linux服务器中不起作用

时间:2017-07-08 12:49:56

标签: codeigniter

使用 codeigniter 创建网站。所有代码都在 localhost(XAMPP)

但是同样的代码在Linux服务器中不起作用,显示错误,如

  

遇到未捕获的异常

     

输入:RuntimeException

     

消息:无法找到您指定的模型:Admin_user

     

文件名:/home/capitalw/public_html/domain/system/core/Loader.php

     

行号:344

     

回溯:

     

文件:/home/capitalw/public_html/domain/application/controllers/Admin.php   行:10   功能:型号

     

文件:/home/capitalw/public_html/domain/index.php   行:315   功能:require_once

这里我的代码是

应用/控制器/ admin.php的

class Admin extends CI_Controller {

    public function __construct(){
        parent::__construct();
        //$this->load->library('common');
        $this->load->library('form_validation');
        $this->load->model('admin_user');

    }
}

应用/模型/ admin_user.php

class Admin_user extends CI_Model {

    function __construct()
    {
        parent::__construct();

    }
//some inser update codes here


}

2 个答案:

答案 0 :(得分:2)

确保您的文件名仅首字母大写开头其他小写。 https://www.codeigniter.com/user_guide/general/styleguide.html#file-naming

  

Admin_user.php

  

admin_user.php

https://www.codeigniter.com/user_guide/general/styleguide.html#class-and-method-naming

答案 1 :(得分:2)

更改文件名

<?php//CREDENTIALS FOR DB
    define ('DBSERVER', 'localhost');
    define ('DBUSER', 'user');
    define ('DBPASS','password');
    define ('DBNAME','dbname');

    //LET'S INITIATE CONNECT TO DB
    $connection = mysqli_connect(DBSERVER, DBUSER, DBPASS,"DBNAME") or die("Can't connect to server. Please check credentials and try again");


    $city= mysqli_real_escape_string($_POST['city']); // $_POST is an array (not a function)
    // mysqli_real_escape_string is to prevent sql injection

    $sql = "SELECT username FROM ".TABLENAME." WHERE city='".$city."'"; // City must enclosed in two quotations

    $query = mysqli_query($connection,$sql);

    if(mysqli_num_rows($query) != 0)

    {
        echo('ADDRESS_EXISTS');
    }
?>

admin_model.php

的Linux&#39;文件系统区分大小写。