0
votes

I do not understand how to fix this codes:

return $this->db->update('slideshow');

I have tried several codes like changing it to $query or $query_result etc. and the error still exist. I still have to use $this->db->update('');

controllers/Cuploadfile.php

function uploadedit()
{

    $data['images'] = ''; // Need to place it here and get images here.

    //set preferences
    $config['upload_path'] = './uploads/';
    $config['allowed_types'] = 'jpg|gif';
    $config['max_size']    = '500000';

    //load upload class library
    $this->load->library('upload', $config);
    $this->load->model('Mpages');


    if (!$this->upload->do_upload('filename'))
    {
        // case - failure
        $upload_error = array('error' => $this->upload->display_errors());
        $this->load->view('addslideshows', $upload_error);
    }
    else
    {
        // case - success
        $upload_data = $this->upload->data();           
        $filename = $upload_data['file_name'];
        $image_id = $this->uri->segment(3);

        $data['images'] = $this->Mpages->edit_slideshow($filename, $image_id);

        $data['success_msg'] = '<div class="alert alert-success text-center">Your file <strong>' . $upload_data['file_name'] . '</strong> was successfully uploaded!</div>';
        $this->load->view('editslideshows', $data);
    }
}

models/Mpages.php

public function edit_slideshow($filename, $image_id)
{   

    $this->db->set('slideshow_image', $filename);
    $this->db->where('image_id', $image_id);
    return $this->db->update('slideshow');

}
2

2 Answers

0
votes

Change your Model's function to this

public function edit_slideshow($filename, $image_id){
    $this->db->where('image_id', $image_id);
    $this->db->update('slideshow', $filename);

    if($this->db->affected_rows() > 0){
       return true;
    }else{
       return false;
    }
}
0
votes

rewrite your model

public function edit_slideshow($filename, $image_id)
{   
$this->db->set('slideshow_image', $filename);
$this->db->where('image_id', $image_id);
$update=$this->db->update('slideshow');
if($update)
{
  return true;
}
  return false;
}