两个错误
A PHP Error was encountered
Severity: Notice
Message: Use of undefined constant model_users - assumed 'model_users'
Filename: controllers/main.php
Line Number: 110
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);
}
我可以知道如何修复它吗?在上面提到的代码中没有未来的错误。提前谢谢..
答案 0 :(得分:0)
您错过了"
..将您的模型名称传递为字符串...
$this->load->model("model_users");
第二个错误,
您需要添加()
,因为您正在调用名为add_database
$this->model_users->add_database();
答案 1 :(得分:0)
加载模型的语法错误。只需将模型的名称指定为字符串即可 它会是这样的。
$this->load->model("model_users");
如果再次出现错误,请检查您为模型指定的名称 你的行可能是这样的。
class Model_users extends CI_Model{
}
答案 2 :(得分:0)
您是否已在config / autoload.php中加载数据库库
$autoload['libraries'] = array('database');