0

我的项目有错误,你能帮帮我吗?这是我的代码:

$q_cek_login = $this->db->get_where('tbl_karyawan', array('username' => $u, 'password' => $p));
if(count($q_cek_login->result())>0)
{
    foreach($q_cek_login->result() as $qck)
    {

        if($qck->id_jabatan==1)
        {
            foreach($q_cek_login->result() as $qad)
            {
                $sess_data['logged_in'] = 'yesGetMeLogin';
                $sess_data['username'] = $qad->username;
                $sess_data['nama_pengguna'] = $qad->nama;
                $sess_data['id_jabatan'] = $qad->id_jabatan;
                $this->session->set_userdata($sess_data);
            }
            //header('location:'.base_url().'pemesanan/pending');
        }
    }
}

然后我得到这个错误:

A PHP Error was encountered

严重性:通知

消息:未定义的属性:stdClass::$id_jabatan

文件名:models/model_digor.php

行号:26

全部…………

4

1 回答 1

0

试试这样写——

if(isset($qck->id_jabatan) && $qck->id_jabatan==1)
于 2013-11-04T08:44:34.703 回答