我的模型中发生了以下情况:
public function load_user_menu($username)
{
$this->db->select('*');
$this->db->from('menu');
$this->db->where('username', $username);
$query = $this->db->get();
return $query->result();
}
以及我的控制器中的以下内容:
public function index()
{
/*If user previously logged in and not logged out, username remains in session.
load username and load profile data.
*/
//check if user logged in or not
if(($this->session->userdata('username')!=""))
{
//load data from model
$profile = array();
$username = $this->session->userdata('username');
$result = $this->profileModel->user_profile($username);
foreach($result as &$value)
{
$profile['userdetails'] = $value;
}
$this->load->view('profile', $profile);
}else{
//redirect to login function
$this->login();
}
}
但我在个人资料视图上遇到错误。我确定我访问它们是错误的,因为我正在这样做:
<? echo $userdetails['profilepic']; ?>
除了这个错误,什么都没有显示:
遇到 PHP 错误
严重性:通知
消息:试图获取非对象的属性
文件名:控制器/profile.php
行号:60
这是肯定的,因为访问错误。如何根据上述内容访问详细信息?