mercredi 23 juin 2021

Cannot use object of type CI_DB_mysqli_result as array in CODEIGNITER

Hello I got the this result Type: Error

Message: Cannot use object of type CI_DB_mysqli_result as array

Filename: C:\xampp\htdocs\myapp\application\views\form_edit.php

Line Number: 32

Type: Error

Message: Cannot use object of type CI_DB_mysqli_result as array

Filename: C:\xampp\htdocs\myapp\application\views\form_edit.php

Line Number: 32

Type: Error

Message: Cannot use object of type CI_DB_mysqli_result as array

Filename: C:\xampp\htdocs\myapp\application\views\form_edit.php

Line Number: 32

Type: Error

Message: Cannot use object of type CI_DB_mysqli_result as array

Filename: C:\xampp\htdocs\myapp\application\views\form_edit.php

Line Number: 32

This is My Views Code

<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
        <div class="alert alert-danger">
            <?= validation_errors();?>
        </div>
    <?= form_open_multipart(); ?>
    <div class="form-grup">
    <label>Judul</label>
        <?= form_input('title' , $blog["title"] , 'class="form-control"');?>
    </div>
        <div class="form-grup">
            <label>Content</label>
                <?= form_textarea('content' , $blog["content"] , 'class="form-control"');?>
        </div>
            <div class="form-grup">
                <label>URl</label>
                    <?= form_input('url' , $blog["url"] , 'class="form-control" 
                     autocomplete="off"');?>
            </div>
            <div class="form-grup">
                <label>Cover</label>
                    <?= form_upload('cover' , $blog["cover"] , 'class="form-control"');?>
            </div>
        <br/>
        <button class="btn btn-primary" type ="submit">EDIT</button>
  <?= form_close(); ?>
  </div>
     </div>
          </div>

This is My Controllers Code

  public function edit($id)
  {
  $query = $this->Blog_model->getSingleBlog('id' , $id);
  $data['blog']=$this->Blog_model->getSingleBlog('id',$id);
    $this->form_validation->set_rules('title' , 'Judul' , 'required');
    $this->form_validation->set_rules('url' , 'URL' , 'required|alpha_dash');
    $this->form_validation->set_rules('content' , 'Content' , 'required');
//konfigurasi upload    
    if($this->form_validation->run()===TRUE){
    $post['title']  =$this->input->post('title');
    $post['content']=$this->input->post('content');
    $post['url']    =$this->input->post('url'); 
    $config['upload_path']         = './uploads/';
    $config['allowed_types']        = 'gif|jpg|png';
    $config['max_size']             = 1000;
    $config['max_width']            = 2000;
    $config['max_height']           = 1600;
    $this->load->library('upload', $config);
    $this->upload->do_upload('cover');
    if (!empty( $this->upload->data()['file_name']) )
    {
        $post['cover']=$this->upload->data()['file_name'];
    }
    
    $id=$this->Blog_model->updateBlog($id,$post);
    if($id){
        echo "Data berhasil disimpan";
    }
    else{
        echo "Data gagal disimpan";
    }
    
}
$this->load->view('form_edit',$data);

}



Aucun commentaire:

Enregistrer un commentaire