Sending Value from controller to model but it shows error " A PHP Error was encountered
Severity: Warning
Message: Illegal string offset 'email'
Filename: models/Pmodel.php
Line Number: 58 "
This is the controller which sends the value
$user_email=$_GET['email'];
$this->load->model('Pmodel');
$data['email']=$this->Pmodel->profile_model($user_email);
$this->load->view('dashboard/profile',$data);
and now the model that acquire the values
public function profile_model($arr)
{
$email=$arr->'email';
print_r($email);
$query=$this->db->where(['user_data.email'=>$email])
->from('user')
->join('user_data', 'user_data.email = user.email')
->get();
$q= $query->result_array();
return $q;
}
When i Print_r($email) it shows error
$email=$arr->'email'
Maybe replace it with this: $email=$arr['email'] Or $email=$arr->email
try to print_r($arr) only.
you can just directly use like this
$query=$this->db->where(['user_data.email'=>$arr]) ->from('user') ->join('user_data', 'user_data.email = user.email') ->get();
Or,
$email = $arr;
$query=$this->db->where(['user_data.email'=>$email]) ->from('user') ->join('user_data', 'user_data.email = user.email') ->get();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.