i'm a newbie in codeigniter , just i got this error:
A PHP Error was encountered
Severity: Notice
Message: Array to string conversion
Filename: views/coba.php
Line Number: 52
and still i can't solve it. this my code on controller:
public function getvalue()
{
$result = $this->admin_model->harga();
$data = array(
'harga' => $result,
);
if ($this->input->post('btnKirim')==true) {
$data['nama']=$this->input->post('nama');
$data['tgl_masuk']=$this->input->post('tgl_masuk');
$data['tgl_ambil']=$this->input->post('tgl_ambil');
$data['berat']=$this->input->post('berat');
$data['status']=$this->input->post('status');
}
$data['judul'] = 'Halaman Pegawai';
$data['content'] = 'coba';
$this->load->view('template/index',$data);
}
and this code for my model :
public function harga(){
$query= $this->db->query('SELECT harga from satuan');
return $query->result();
}
it's my view.php on where i got this error message:
<div class="form-group">
<label for="total" class="control-label">Total Harga</label>
<div>
<input name="total" id="total" type="numeric" class="form-control" value="<?php echo $harga; ?>" readonly='total'>
</div>
</div>
Why am I getting this message, what can I do to solve it?
$this->admin_model->harga()returns an array, but your code expects it to be a string. Check your model's method to see why this happens.print_r($result);and see what is returned