Reputation: 5263
I load a model in a controller. But I have this error:
Message: Undefined property: Captcha::$captcha_model
And also this message:
Fatal error: Call to a member function captcha_insert() on a non-object in C:\xampp\htdocs\ci-framework\application\modules\captcha\controllers\captcha.php on line 31
Everything seems true!
Controller:
$time = $captcha['time'];
$ip_address = $this->input->ip_address();
$word = $captcha['word'];
$this->load->model('captcha/captcha_model');
$value = $this->captcha_model->captcha_insert($time, $ip_address, $word);
model:
class Captcha_model extends CI_model {
public function captcha_insert($time, $ip_address, $word){
$query = $this->db->query("insert into captcha
(time, ip_address, word)
values(?, ?, ?)",
array($time, $ip_address, $word));
if ($query)
return true;
}
}
What's wrong? Thank you very much :)
Upvotes: 3
Views: 837
Reputation: 66
Do this:
$time = $captcha['time'];
$ip_address = $this->input->ip_address();
$word = $captcha['word'];
$this->load->model('captcha_model/captcha_insert');
$value = $this->captcha_model->captcha_insert($time, $ip_address, $word);
Upvotes: 0