Postingan lainnya
Bagaimana cara mengatasi Array to string conversion Codeigniter ?
Mohon bantuannya sya kebingungan ngatasi maslah Array to string conversion..
Controllernya ..
function update(){
$id_p = $this->input->post('id_p');
$NIP = $this->input->post('NIP');
$Nama_penduduk = $this->input->post('Nama_penduduk');
$tgl_lahir = $this->input->post('tgl_lahir');
$jenis_kelamin = $this->input->post('jenis_kelamin');
$Alamat_penduduk = $this->input->post('Alamat_penduduk');
$Pekerjaan = $this->input->post('Pekerjaan');
$agama = $this->input->post('agama');
$No_Hp = $this->input->post('No_Hp');
$data = array(
'NIP' => $NIP,
'Nama_penduduk' => $Nama_penduduk,
'tgl_lahir' => $tgl_lahir,
'jenis_kelamin' => $jenis_kelamin,
'Alamat_penduduk' => $Alamat_penduduk,
'Pekerjaan' => $Pekerjaan,
'agama' => $agama,
'No_Hp' => $No_Hp
);
$where = array(
'id_p' => $id_p
);
$this->db_model->update_data($where,$data,'tb_penduduk');
redirect('penduduk/dataPenduduk');
}
function editdata($id){
$where = array('id_p' => $id);
$data['result'] = $this->db_model->edit_data($where,'tb_penduduk')->result();
$this->load->view('p_admin',['page' => 'penduduk/edit','title'=>'Edit Penduduk','data'=>$data]);
}
Model ..!
function edit_data($where,$table){
return $this->db->get_where($table,$where);
}
function update_data($where,$table,$data){
$this->db->where($where);
$this->db->update($table,$data);
}
2 Jawaban:
Jawaban Terpilih
$this->db_model->update_data($where,$data,'tb_penduduk');
//ganti dengan
$this->db_model->update_data($where,'tb_penduduk', $data);
/*
urutan function update_data($kriteria, $tabel, $data)
Jadi dia akan baca tabel array makanya ndk bisa,, karena seharusnya tabel kan bentuk nya string .... itu dasar error Array to string conversion..inputan harusnya string..malah diinput dg array..
*/
Semoga bermanfaat, Happy Sharing (^_^)
Mohon bantuannya. Saya bingung mengatasi error ini.
ErrorException in routes.php line 77: Array to string conversion in routes.php line 77 at HandleExceptions->handleError('8', 'Array to string conversion', 'C:\xampp\htdocs\laravelapp\app\Http\routes.php', '77', array('router' => object(Router))) in RouteServiceProvider.php line 58 at require() in RouteServiceProvider.php line 58 at RouteServiceProvider->App\Providers{closure}(object(Router)) at call_user_func(object(Closure), object(Router)) in Router.php line 398 at Router->group(array('namespace' => 'App\Http\Controllers', 'middleware' => 'web'), object(Closure)) in RouteServiceProvider.php line 59 at RouteServiceProvider->mapWebRoutes(object(Router)) in RouteServiceProvider.php line 40 at RouteServiceProvider->map(object(Router)) at call_user_func_array(array(object(RouteServiceProvider), 'map'), array(object(Router))) in Container.php line 507 at Container->call(array(object(RouteServiceProvider), 'map')) in RouteServiceProvider.php line 72 at RouteServiceProvider->loadRoutes() in RouteServiceProvider.php line 31 at RouteServiceProvider->boot(object(Router)) in RouteServiceProvider.php line 29 at RouteServiceProvider->boot(object(Router)) at call_user_func_array(array(object(RouteServiceProvider), 'boot'), array(object(Router))) in Container.php line 507 at Container->call(array(object(RouteServiceProvider), 'boot')) in Application.php line 757 at Application->bootProvider(object(RouteServiceProvider)) in Application.php line 740 at Application->Illuminate\Foundation{closure}(object(RouteServiceProvider), '14') at array_walk(array(object(EventServiceProvider), object(RoutingServiceProvider), object(AuthServiceProvider), object(CookieServiceProvider), object(DatabaseServiceProvider), object(EncryptionServiceProvider), object(FilesystemServiceProvider), object(FoundationServiceProvider), object(PaginationServiceProvider), object(SessionServiceProvider), object(ViewServiceProvider), object(AppServiceProvider), object(AuthServiceProvider), object(EventServiceProvider), object(RouteServiceProvider)), object(Closure)) in Application.php line 741 at Application->boot() in BootProviders.php line 17 at BootProviders->bootstrap(object(Application)) in Application.php line 203