请帮助解决我在 Codeigniter 和杂货店中遇到的错误。下面的代码抛出以下消息,我坚持了几天,我完全是菜鸟:(错误:
遇到 PHP 错误
严重性:通知
消息:试图获取非对象的属性
文件名:控制器/examples.php
行号:70
ps:
函数做它需要的,但是上面的错误出现了。
我很欣赏你对此的想法!
function security() {
$method = $this->uri->segment(3); //tell ci that we are working on url segment 3, e.g. delete, update ....
if ($method == "edit" or $method == 'update_validation' or $method == 'delete') {
$id = $this->uri->segment(4); //work on url segment 4, now pointing at posts table primary key
$this->db->where('posts.user_id', $this->session->userdata('id'));
$result = $this->db->get_where('posts', array('id' => $id), 1)->row();
//this is line: 70 if ($result->id != $id)
{
echo "You don't have access";
exit;
}
else return true;
}
}