Note that there are some explanatory texts on larger screens.

plurals
  1. POCodeigniter function skipping
    text
    copied!<p>Hi this is a simple question, however I have now stared at it long enough to realise im simply not seeing the error. If anyone can see where this is going wrong I would be very thankful.</p> <pre><code>public function create() { $this-&gt;load-&gt;model('ticket_model'); if($_POST) { // validate form if($this-&gt;_validate()) { // save updates foreach($_POST as $key =&gt; $value){if(!is_array($value)) $_POST[$key] = htmlspecialchars($value);} if ($_POST['subject'] == '') $body_data['error'][] = "You did not enter a subject."; if ($_POST['priority'] == '') $body_data['error'][] = "You did not select a priority."; if ($_POST['status'] == '') $body_data['error'][] = "You did not select a status."; if ($_POST['ipAddress'] == '') $body_data['error'][] = "You did not enter a ipAddress."; if ($_POST['text_area'] == '') $body_data['error'][] = "You did not enter a message."; else { if (filter_var($_POST['ipAddress'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) == FALSE) $body_data['error'][] = "IP Address is not valid IPV4 Address."; if (filter_var($_POST['ipAddress'], FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE) == FALSE) $body_data['error'][] = "IP Address cannot be from RFC1918 private space."; if (filter_var($_POST['ipAddress'], FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE) == FALSE) $body_data['error'][] = "IP Address cannot be from reserved range."; } if ($_FILES['filename']['name'] != '') { if ($_FILES['filename']['size'] &gt; '1024000') { $body_data['error'][] = "The file you uploaded is too large."; unlink($_FILES['filename']['tmp_name']); $body_data['ticket_list'] = $this-&gt;ticket_model-&gt;list_ticket(); $body_data['ticket_details'] = $this-&gt;ticket_model-&gt;get_ticket($ticket_id); $body_data['ticket_summary'] = $this-&gt;ticket_model-&gt;list_ticket_summary($ticket_id); $body_data['precan_list'] = $this-&gt;ticket_model-&gt;list_messages(); $body_data['users_list'] = $this-&gt;ticket_model-&gt;list_users(); $foot_data['accordian_active'] = 5; $this-&gt;load-&gt;view('head',$head_data); $this-&gt;load-&gt;view('sidebar/service',$head_data); $this-&gt;load-&gt;view('ticket/edit',$body_data); $this-&gt;load-&gt;view('foot',$foot_data); return; } else { //the file is under the specified size. so copy it from temp to import folder and proccess $thisFileHumanName = $_FILES['filename']['name']; $thisFileSize = $_FILES['filename']['size']; $thisServerFileName = strtoupper(uniqid('A')); $thisFileType = $_FILES['filename']['type']; $temp_file_location = $this-&gt;config-&gt;item('rootpath').'/assets/ticketuploads/'.$thisServerFileName; if (!move_uploaded_file($_FILES['filename']['tmp_name'], $temp_file_location)) { $body_data['error'][] = "File could not be moved due to a permissions error."; unlink($_FILES['filename']['tmp_name']); $body_data['ticket_list'] = $this-&gt;ticket_model-&gt;list_ticket(); $body_data['ticket_details'] = $this-&gt;ticket_model-&gt;get_ticket($ticket_id); $body_data['ticket_summary'] = $this-&gt;ticket_model-&gt;list_ticket_summary($ticket_id); $body_data['precan_list'] = $this-&gt;ticket_model-&gt;list_messages(); $body_data['users_list'] = $this-&gt;ticket_model-&gt;list_users(); $foot_data['accordian_active'] = 5; $this-&gt;load-&gt;view('head',$head_data); $this-&gt;load-&gt;view('sidebar/service',$head_data); $this-&gt;load-&gt;view('ticket/edit',$body_data); $this-&gt;load-&gt;view('foot',$foot_data); return; } } } //clean error array $body_data['error'] = array_filter($body_data['error']); if ($body_data['error']) { $body_data['ticket_list'] = $this-&gt;ticket_model-&gt;list_ticket(); $body_data['ticket_details'] = $this-&gt;ticket_model-&gt;get_ticket($ticket_id); $body_data['ticket_summary'] = $this-&gt;ticket_model-&gt;list_ticket_summary($ticket_id); $body_data['precan_list'] = $this-&gt;ticket_model-&gt;list_messages(); $body_data['users_list'] = $this-&gt;ticket_model-&gt;list_users(); unlink($_FILES['filename']['tmp_name']); $foot_data['accordian_active'] = 5; $this-&gt;load-&gt;view('head',$head_data); $this-&gt;load-&gt;view('sidebar/service',$head_data); $this-&gt;load-&gt;view('ticket/edit',$body_data); $this-&gt;load-&gt;view('foot',$foot_data); return; } else { $_POST['userId'] = $this-&gt;session-&gt;get_user_id(); $thisMessageId = $this-&gt;ticket_model-&gt;save_message($_POST); if ($_FILES['filename']['name'] != '') { //set variables for save $_POST['file_path'] = $temp_file_location; $_POST['file_name'] = $thisFileHumanName; $_POST['file_size'] = $thisFileSize; $_POST['file_type'] = $thisFileType; $_POST['messageId'] = $thisMessageId; $this-&gt;ticket_model-&gt;save_upload($_POST); } $this-&gt;ticket_model-&gt;save_ticket($_POST); redirect(base_url().'ticket/'); return; } } } $body_data['ticket_list'] = $this-&gt;ticket_model-&gt;list_ticket(); $body_data['message_list'] = $this-&gt;ticket_model-&gt;list_message($ticket_id); $body_data['customer_list'] = $this-&gt;ticket_model-&gt;list_customers(); $body_data['users_list'] = $this-&gt;ticket_model-&gt;list_users(); $foot_data['accordian_active'] = 5; $foot_data['contact_search'] = true; $this-&gt;load-&gt;view('head',$head_data); $this-&gt;load-&gt;view('sidebar/service',$head_data); $this-&gt;load-&gt;view('ticket/create',$body_data); $this-&gt;load-&gt;view('foot',$foot_data); return; } </code></pre> <p>This is my code, and everything is going well, except for the section where i save the upload, as nothing seems to be firing the model, even thought there is a file being posted from the from submit and there for the filename being posted is <code>!= ''</code>...... e.g</p> <pre><code>if ($_FILES['filename']['name'] != '') { //set variables for save $_POST['file_path'] = $temp_file_location; $_POST['file_name'] = $thisFileHumanName; $_POST['file_size'] = $thisFileSize; $_POST['file_type'] = $thisFileType; $_POST['messageId'] = $thisMessageId; $this-&gt;ticket_model-&gt;save_upload($_POST); } </code></pre> <p>my apologies if this is silly mistake.</p>
 

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