Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP White Page Controller Issue
    text
    copied!<p>I have a section of my code that is causing my whole page to load white with no error message.</p> <p>I have debuged my code and the following section is causing my issue but I cannot work out why:</p> <p><strong>Problem Code:</strong></p> <pre><code> if($this-&gt;image_model-&gt;updatePage($id, $caption)) { $data['title'] = 'Image Captions'; $data['cms_pages'] = $this-&gt;navigation_model-&gt;getCMSPages(); $data['sales_pages'] = $this-&gt;sales_model-&gt;getSalesPages(); $data['get_images'] = $this-&gt;image_model-&gt;getImages(); $data['content'] = $this-&gt;load-&gt;view('admin/imagecaption', $data, TRUE); #Loads the "content" $this-&gt;load-&gt;view('admintemplate', $data); #Loads the given template and passes the $data['content'] into it }//END if updatePage </code></pre> <p><strong>Full Controller Document:</strong></p> <pre><code>function index(){ if(!$this-&gt;session-&gt;userdata('logged_in'))redirect('admin/home'); $data['title'] = 'Image Captions'; $data['cms_pages'] = $this-&gt;navigation_model-&gt;getCMSPages(); $data['sales_pages'] = $this-&gt;sales_model-&gt;getSalesPages(); $data['get_images'] = $this-&gt;image_model-&gt;getImages(); $data['content'] = $this-&gt;load-&gt;view('admin/imagecaption', $data, TRUE); #Loads the "content" $this-&gt;load-&gt;view('admintemplate', $data); #Loads the given template and passes the $data['content'] into it if ($this-&gt;input-&gt;post('submit')){ #The User has submitted updates, lets begin! #Set The validation Rules $this-&gt;form_validation-&gt;set_rules('captionInput', 'Caption', 'trim|required|xss_clean'); if ($this-&gt;form_validation-&gt;run() == FALSE){ #Form Validation Fails Load The Default Page $data['title'] = 'Image Captions'; $data['cms_pages'] = $this-&gt;navigation_model-&gt;getCMSPages(); $data['sales_pages'] = $this-&gt;sales_model-&gt;getSalesPages(); $data['get_images'] = $this-&gt;image_model-&gt;getImages(); $data['content'] = $this-&gt;load-&gt;view('admin/imagecaption', $data, TRUE); #Loads the "content" $this-&gt;load-&gt;view('admintemplate', $data); #Loads the given template and passes the $data['content'] into it }// END Form Validation #Form Validation passed, so lets continue updating. #lets set some variables to pass into the database for editing. $caption = $this-&gt;input-&gt;post('captionInput', TRUE); $this-&gt;db-&gt;escape($caption); # Lets check for security and mel objects :) #Now if imageCaption fails to update the database then show "there was a problem". if($this-&gt;image_model-&gt;updatePage($id, $caption)) { $data['title'] = 'Image Captions'; $data['cms_pages'] = $this-&gt;navigation_model-&gt;getCMSPages(); $data['sales_pages'] = $this-&gt;sales_model-&gt;getSalesPages(); $data['get_images'] = $this-&gt;image_model-&gt;getImages(); $data['content'] = $this-&gt;load-&gt;view('admin/imagecaption', $data, TRUE); #Loads the "content" $this-&gt;load-&gt;view('admintemplate', $data); #Loads the given template and passes the $data['content'] into it }//END if updatePage }else{ $data['title'] = 'Image Captions'; $data['cms_pages'] = $this-&gt;navigation_model-&gt;getCMSPages(); $data['sales_pages'] = $this-&gt;sales_model-&gt;getSalesPages(); $data['get_images'] = $this-&gt;image_model-&gt;getImages(); $data['content'] = $this-&gt;load-&gt;view('admin/imagecaption', $data, TRUE); #Loads the "content" $this-&gt;load-&gt;view('admintemplate', $data); #Loads the given template and passes the $data['content'] into it } //END Submit } //END function index() } </code></pre> <p><strong>Image Model:</strong></p> <pre><code>class Image_model extends CI_Model { function __construct() { parent::__construct(); } function getImages($path = NULL) { foreach($this-&gt;db-&gt;get('images')-&gt;result_array() as $r) { $rows[] = $r; } return $rows; } function addImage($imgdata) { $this-&gt;db-&gt;insert('images',$imgdata); return; } function deleteimage($id){ $this-&gt;db-&gt;where('id', $id); $q = $this-&gt;db-&gt;get('images'); $row = $q-&gt;row_array(); if ($q-&gt;num_rows() &gt; 0){ //delete from the database $this-&gt;db-&gt;where('id', $id); $this-&gt;db-&gt;delete('images'); //lets delete the image unlink("includes/uploads/gallery/".$row['imagename']); //lets delete the thumb. unlink("includes/uploads/gallery/thumbs/".$row['thumbname']); }//END if num_rows }//END function deleteImage($id) function updateCaption($id = NULL, $caption = NULL){ #set the $data passed to the function into an array, content being the column name. $data = array('description' =&gt; $caption); $this -&gt;db-&gt;where('id',$id); $this-&gt;db-&gt;update('images', $data); return TRUE; } }//END class Image_model </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload