php - Why am I getting an "array to string conversion" error in CodeIgniter? -


i'm having problem error:

array string conversion

here's code:

controller:

function get_tariff() {          $this->load->model('model_tariff');    $data['destination']=$this->input->post('dest',true);    $data['lines']=$this->input->post('lines',true);    $data['weight']=$this->input->post('weight',true);    $data['priceperkg']=$this->model_tariff->get_tariff();    $data['pricetotal']=$data['priceperkg']* $data['weight'];    $this->load->view('tariff_result',$data); } 

model:

function get_tariff() {            $destination=$this->input->post('dest');    $lines=$this->input->post('lines');    $weightt=$this->input->post('weight');    $this->db->select('price');    $this->db->from('view_tariff');    $this->db->where('city_name',$destination);    $this->db->where('lines',$lines);    $price=$this->db->get();    return $price->result();     } 

view:

price per kg <?php echo $priceperkg?>; bayar total <?php echo $pricetotall?>; 

the codeigniter database method result() returns array of objects, not string literal (price). need further transformations. example, if expecting single row, try row() returns single object. in turn, can reference property price:

return $price->row()->price; 

or, can treat several other ways.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -