• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[help] error array to string conversion

#1
Error..!
PHP Code:
A PHP Error was encountered
Severity
Notice

Message
: Array to string conversion

Filename
database/DB_driver.php

Line Number
1528

Backtrace
:

FileC:\xampp\htdocs\simendes\application\models\db_model.php
Line
54
Function: update

File
C:\xampp\htdocs\simendes\application\controllers\penduduk.php
Line
81
Function: update_data

File
C:\xampp\htdocs\simendes\index.php
Line
315
Function: require_once 

[Image: MYrSL6G]

Controller ..!

Code:
    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


    );

    print_r($data);
    print_r($where);

    $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 .!
Code:
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);
        
    }
Reply

#2
You're passing the paramaters for the update_data function in the wrong order.

Your function:
PHP Code:
function update_data($where,$table,$data

To call the function:
PHP Code:
$this->db_model->update_data($where,'tb_penduduk',$data); 
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2018 MyBB Group.