0

两个错误

错误 1

A PHP Error was encountered

Severity: Notice

Message: Use of undefined constant model_users - assumed 'model_users'

Filename: controllers/main.php

Line Number: 110

错误 2

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Main::$add_database

Filename: core/Model.php

Line Number: 51

控制器

if ($this->form_validation->run() == TRUE)
{
    $this->load->model(model_users);          //Line 110
    $this->model_users->add_database;
}else{
    $this->load->view('signup');
}

模型

public function add_database() {


$usersdata = array (
                'email'     =>  $this->input->post('email'),
                'password'  =>  md5($this->input->post('password')),
);

$regdetails = array (
                'full_name'         =>  $this->input->post('full_name'),
                'gender'            =>  $this->input->post('gender'),
                'dob'               =>  $this->input->post('dob'),
                'address'           =>  $this->input->post('address'),
                'city'              =>  $this->input->post('city'),
                'state'             =>  $this->input->post('state'),
                'country'           =>  $this->input->post('country'),
                'pin'               =>  $this->input->post('zip'),
                'alternative_email' =>  $this->input->post('alt_email'),
                'phone'             =>  $this->input->post('phone'),
                'mobile'            =>  $this->input->post('mobile'),
);


    $query = $this->db->insert('users',$usersdata);
    $this->db->insert('tbl_studentreg',$regdetails);
}

我可以知道如何解决吗?在上面提到的代码中没有未来的错误。提前致谢..

4

3 回答 3

0

您错过了"..将您的型号名称作为字符串传递...

 $this->load->model("model_users");   

文档在这里

第二个错误,

您需要添加(),因为您正在调用一个名为 add_database 的函数

 $this->model_users->add_database();
于 2013-04-08T12:45:44.973 回答
0

您加载模型的语法是错误的。只需将模型的名称指定为字符串,它看起来像这样。

$this->load->model("model_users"); 

如果再次发生错误,请检查您为模型指定的名称,您的行可能是这样的。

class Model_users extends CI_Model{

}

于 2013-04-08T13:04:46.977 回答
0

你有没有在 config/autoload.php 中加载数据库库

$autoload['libraries'] = array('database');
于 2013-04-08T13:32:58.337 回答