Welcome Guest, Not a member yet? Register   Sign In
Object of class stdClass could not be converted to string
#1

I am sending data from android. Into android when i input data from edittext, then my code works fine. But when i am selecting some data from dropdown, then this error occured.

My Controller class code is.......

$raw = $this -> input -> post();
$data = json_decode($raw['json']);
//all data fetch from json object.....
$first_name = $data ->first_name;
$middle_name = $data ->middle_name;
$last_name = $data ->last_name;
$phone_no = $data->phone_no;
$user_id = $data->user_id;
$amount = $data->amount;
$currency_type = $data->currency_type;
$date = $data->date;
$payment_mode = $data->payment_mode;
$transaction_status = $data->transaction_status;
$description = $data->description;
$image_file = $data->image;

$this-> load ->model('EQFinance_db');
$response = $this->EQFinance_db-> add_transaction($first_name,$middle_name,$last_name,$phone_no,$user_id,$amount,$currency_type,$date,
$payment_mode,$transaction_status,$description,$image_file);

-------------------------------------------------------------------------------------------------
and My Model class code is......................................

$query = $this -> db -> select("ID")-> get_where('person',array('first_name'=>$first_name,'last_name'=>$last_name,'user_id'=>$user_id));
if($query -> num_rows() > 0){
$other_party = $query -> row();
$transaction_array = array('other_party'=>$other_party,'user_id'=>$user_id,'amount'=>$amount,'currency_type'=>$currency_type,'date'=>$date,
'payment_mode'=>$payment_mode,'transaction_status'=>$transaction_status,'description'=>$description,'image'=>$image);
if($this-> db -> insert('transaction',$transaction_array)){
return array("success"=> $success = 1);
}else{
return array("success"=> $success = 0);
}
}else{
$person_array = array('first_name'=>$first_name,'middle_name'=>$middle_name,'last_name'=>$last_name,'phone_no'=>$phone_no,'user_id'=>$user_id);
$this -> db -> insert('person',$person_array);
$other_party = $this -> db -> insert_id();
$transaction_array = array('other_party'=>$other_party,'user_id'=>$user_id,'amount'=>$amount,'currency_type'=>$currency_type,'date'=>$date,
'payment_mode'=>$payment_mode,'transaction_status'=>$transaction_status,'description'=>$description,'image'=>$image);
if($this-> db -> insert('transaction',$transaction_array)){
return array("success"=> $success = 1);
}else{
return array("success"=> $success = 0);
}
}

Attached Files Thumbnail(s)
   
Reply
#2

Since none of this appears to be relevant to the error message in the subject line of your message, I'm guessing that the error has something to do with whatever data you've placed into the json variable in your POST. You really need to check your data before using it in database queries, and you really need to be careful about what you're encoding/decoding in JSON. By default, json_decode() will create stdClass objects from any objects you've encoded in the JSON string. More than likely, you encoded a control or something a little more complex than the value of a form control, then passed it straight through to $this->db->insert().
Reply




Theme © iAndrew 2016 - Forum software by © MyBB