2017-07-31 117 views
2

嚴重性:4096對象無法轉換爲字符串

消息:類Login_Model的對象不能被轉換成字符串

文件名:型號/ login_model.php

線號碼:27

public function login() { 
    //check user type 

    $this->_table_name = 'tbl_employee_login'; 
    $this->_order_by = 'employee_login_id'; 
    $employee = $this->get_by(array(
     'email' => $this->input->post('email'), 
     'password' => $this->$this->input->post('password'), LINE NUMBER 27 
     'activate' => 1 
    ), TRUE); 
    /*employee*/ 
    $this->_table_name = 'driver'; 
    $this->_order_by = 'driver_id'; 

    $driver = $this->get_by(array(
     'email' => $this->input->post('email'), 
     'password' => $this->$this->input->post('password'), 
    ), TRUE); 
    /*driver*/ 
    $this->_table_name = 'tbl_user'; 
    $this->_order_by = 'user_id'; 

    $admin = $this->get_by(array(
     'email' => $this->input->post('email'), 
     'password' => $this->$this->input->post('password'), 
      ), TRUE); 
    if ($admin) { 
     $data = array(
      'email' => $admin->email, 
      'first_name' => $admin->first_name, 
      'last_name' => $admin->last_name, 
      'employee_id' => $admin->user_id, 
      'loggedin' => TRUE, 
      'user_type' => 1, 
      'user_flag' => $admin->flag, 
      'url' => 'admin/dashboard', 
     ); 
     $this->session->set_userdata($data); 
    } elseif($employee) { 

     if (count($employee)) { 
      // Log in user 
      $employee_id = $employee->employee_id; 
      $this->_table_name = "tbl_employee"; //table name 
      $this->_order_by = "employee_id"; 
      $user_info = $this->get_by(array('employee_id' => $employee_id), TRUE); 

      $data = array(
       'email' => $employee->email, 
       'employee_id' => $employee->employee_id, 
       'user_name' => $user_info->first_name . ' ' . $user_info->last_name, 
       'employee_login_id' => $employee->employee_login_id, 
       'loggedin' => TRUE, 
       'user_type' => 2, 
       'url' => 'employee/dashboard', 
      ); 
      $this->session->set_userdata($data); 
     } 
    } 
    elseif($driver){ 
     $data = array(
      'email' => $driver->email, 
      'drive_id' => $driver->driver_id, 
      'name' => $driver->name, 
      'loggedin' => TRUE, 
      'user_type' => 3, 
      'url' => 'driver/dashboard', 
     ); 
     $this->session->set_userdata($data); 
    } 
} 

任何一個可以給我一個解決這個錯誤的解決方案。我嘗試使用管理員用戶名和密碼登錄,但它告訴我這一點,更像是一串誤差轉換

+0

您可以發佈您全班......你剛剛發佈的功能..所以,我可以找到行號27 – Farsay

+0

@Farsay,'「密碼」 => $此 - > $這個 - >輸入 - >後('password'),LINE NUMBER 27' –

+0

爲什麼你有'$ this - > $ this'? – Barmar

回答

2

typo$this

'password' => $this->$this->input->post('password'), 

更改爲

'password' =>$this->input->post('password'), 

注:而且same mistake在很多other lines也太在意了。

+0

謝謝@JYoThI –

+0

是的,我會在網站給我5分鐘後的權限後標記 –

+0

酷:)很高興幫助你:) – JYoThI

1

它應該是$這個 - >輸入 - >後(「密碼」)

1

你有鍵入錯誤是$這個 - > $這在3個地方在你的代碼。