0

am getting an error of array to string conversion.this is my control

public function report()
{
    $from=$this->input->post('from_date');
    $to = $this->input->post('to_date');
    $data['result']= $this->Account_model->get_report($from,$to)->result();
    $data['total'] = $total= $this->Account_model->get_total_amount($from,$to)->result();
    var_dump($total);
    $this->load->view('report_payment_details',$data);

}

this is my model

public function get_total_amount($from,$to)
{
    $this->db->join('payment','payment.order_id=services.id','left');
    $this->db->select('services.id,sum(payment.actual_amount) as total_amount');
    $this->db->join('customer','customer.id=services.customer_id');
    $this->db->order_by('services.id','desc');
    $this->db->where('date >=', $from);
    $this->db->where('date <=', $to);
    return $this->db->get('services');

this is my view

<td><?php echo $total; ?></td>  

here i want to get the total amount with in two dates but getting error of array to string conversion

user_777
  • 845
  • 1
  • 9
  • 25
  • because you are trying to echo an array. Try using `$total->total_amount;` And if you are fetching one record use `row()` inserted of `result()` Hope you got my point. –  Jun 20 '16 at 13:32
  • In most cases you can copy your error message and paste it into google search. You could get result like [this one](http://stackoverflow.com/questions/20017409/how-to-solve-error-notice-array-to-string-conversion-in). – Tpojka Jun 20 '16 at 15:48

0 Answers0