title: Invalid argument supplied for foreach()
body: <p>I do not understand how to fix this codes:</p>
  
  <pre><code>return $this-&gt;db-&gt;update('slideshow');
  </code></pre>
  
  <p>I have tried several codes like changing it to <code>$query</code> or <code>$query_result</code> etc. and the error still exist.  I still have to use <code>$this-&gt;db-&gt;update('');</code></p>
  
  <p>controllers/Cuploadfile.php</p>
  
  <pre><code>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-&gt;load-&gt;library('upload', $config);
      $this-&gt;load-&gt;model('Mpages');
  
  
      if (!$this-&gt;upload-&gt;do_upload('filename'))
      {
          // case - failure
          $upload_error = array('error' =&gt; $this-&gt;upload-&gt;display_errors());
          $this-&gt;load-&gt;view('addslideshows', $upload_error);
      }
      else
      {
          // case - success
          $upload_data = $this-&gt;upload-&gt;data();           
          $filename = $upload_data['file_name'];
          $image_id = $this-&gt;uri-&gt;segment(3);
  
          $data['images'] = $this-&gt;Mpages-&gt;edit_slideshow($filename, $image_id);
  
          $data['success_msg'] = '&lt;div class="alert alert-success text-center"&gt;Your file &lt;strong&gt;' . $upload_data['file_name'] . '&lt;/strong&gt; was successfully uploaded!&lt;/div&gt;';
          $this-&gt;load-&gt;view('editslideshows', $data);
      }
  }
  </code></pre>
  
  <p>models/Mpages.php</p>
  
  <pre><code>public function edit_slideshow($filename, $image_id)
  {   
  
      $this-&gt;db-&gt;set('slideshow_image', $filename);
      $this-&gt;db-&gt;where('image_id', $image_id);
      return $this-&gt;db-&gt;update('slideshow');
  
  }
  </code></pre>