dqjcb132285 2015-09-13 08:51
浏览 9
已采纳

试图获得非对象的属性

I'm trying to pass id of user from one view to another and display profile details of respective id.But instead of displaying profile details i get error message "trying to get property of non-object.

Here is the first view

<td class="user-name"><a href="<?php echo site_url() . 'admin/users/members_details/' . $allusers->p_u_id; ?>"> <?php echo $allusers->comp_person_name ?></a>   <span>Subscriber</span> </td>

controllers : members_details method

public function members_details () {
     $data['udetails']= $this->user_model->user_details(array('u_id' => $this->uri->segment(4) , 'u_delete' => 1 ));
 $this->layout->view("admin/members_details", $data);
}

user_details model

 function user_details($where = '', $order = '', $select = '') {
        if (!$select)
            $select = array('users.u_id', 'users.u_email', 'u_status', 'u_group', 'user_profile.*', 'cities.*', 'country.*');

        $joins = array(array('table' => 'user_profile', 'condition' => 'user_profile.p_u_id=users.u_id', 'jointype' => 'INNER'),
            array('table' => 'cities', 'condition' => 'user_profile.comp_city=cities.id', 'jointype' => 'INNER'),
            array('table' => 'country', 'condition' => 'user_profile.comp_country=country.id', 'jointype' => 'INNER'));
        if ($order)
            $this->db->order_by($order);
        else
            $this->db->order_by('u_id  DESC');

        return $this->get_joins('users', $where, $joins, $select);
    }

members_details view

<a href="#" class="user-name">
<?php echo $udetails->comp_person_name ?> 
<span class="user-status is-online"></span>

Now when i trying to display comp_person_name , i get above said error. Where i went wrong?

  • 写回答

1条回答 默认 最新

  • douwu3763 2015-09-13 10:36
    关注

    data returns an array .So replacing

     $udetails->comp_person_name  
    

    with

    $udetails['0']->comp_person_name
    

    solved the issue

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分