Note that there are some explanatory texts on larger screens.

plurals
  1. POCodeIgniter Disallowed Key Characters after submitting the form
    primarykey
    data
    text
    <p>CodeIgniter is giving me a Disallowed Key Characters error. even after successfully inserting data in database. here is my code.:</p> <ul> <li>Controller:</li> </ul> <p>class applyleavectrl extends CI_Controller {</p> <pre><code>public function __construct() { parent::__construct(); $this-&gt;load-&gt;model('fill_in','fill'); //model fill in $this-&gt;load-&gt;model('mdl_employee','emp'); $id = $this-&gt;session-&gt;userdata('id'); } public function index() { $id = $this-&gt;session-&gt;userdata('id'); $this-&gt;form_validation-&gt;set_rules('leave_type', 'Leave Type', 'required|callback_check_select'); $this-&gt;form_validation-&gt;set_message('check_select', 'You need to select a leave type'); $this-&gt;form_validation-&gt;set_rules('from_date', 'From Date', 'required'); $this-&gt;form_validation-&gt;set_rules('to_date', 'To Date', 'required'); $this-&gt;form_validation-&gt;set_error_delimiters('&lt;font size="1" face="helvetica" color="red"&gt;', '&lt;/font&gt;'); if ($this-&gt;form_validation-&gt;run() == FALSE) { $data['employee_header_menus'] = $this-&gt;load-&gt;view('employee_header_menus', NULL, TRUE); $data['employee_header_logout'] = $this-&gt;load-&gt;view('employee_header_logout', NULL, TRUE); $data['leave_type'] = $this-&gt;fill-&gt;fill_leave_type(); $this-&gt;load-&gt;view('employee/applyleave', $data); } else { $id = $this-&gt;session-&gt;userdata('id'); $P1 = $this-&gt;input-&gt;post('leave_type'); $P2 = $this-&gt;input-&gt;post('from_date'); $P3 = $this-&gt;input-&gt;post('to_date'); $P4 = $this-&gt;input-&gt;post('comments'); $this-&gt;emp-&gt;insert_employee_leave($id, $P1, $P2, $P3, $P4); redirect('employee/applyleavectrl'); } } function check_select($post_string) { return $post_string == '0' ? FALSE : TRUE;} } </code></pre> <p>model</p> <pre><code>public function insert_employee_leave($id, $P1, $P2, $P3, $P4) { $value = array( 'empid' =&gt; $id, 'leave_type' =&gt; $P1, 'from_date' =&gt; $P2, 'to_date' =&gt; $P3, 'comments' =&gt; $P4); $this-&gt;db-&gt;insert('employee_leave', $value); } </code></pre> <p>and the view is </p> <pre><code>&lt;?php $attributes = array('autocomplete' =&gt; "off"); echo form_open('employee/applyleavectrl', $attributes); ?&gt; &lt;div class="row"&gt; &lt;div class="span3 offset2"&gt; &lt;label&gt;Leave Type&lt;/label&gt; &lt;select name="leave_type"&gt; &lt;option selected value="0"&gt;Select Leave Type&lt;/option&gt; &lt;?php foreach($leave_type as $row): ?&gt; &lt;option value="&lt;?php echo $row['ID']; ?&gt;"&gt;&lt;?php echo $row['type']; ?&gt;&lt;/option&gt; &lt;?php endforeach; ?&gt; &lt;/select&gt; &lt;/div&gt; &lt;div class="span3 offset2"&gt; &lt;label&gt;From Date&lt;/label&gt; &lt;input id="from_date" name="from_date" type="date"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="row"&gt; &lt;div class="span3 offset2"&gt; &lt;label &gt;Leave Balance&lt;/label&gt; &lt;input name="leave_bal" id='leave_bal' type="text" disabled&gt; &lt;/div&gt; &lt;div class="span3 offset2"&gt; &lt;label&gt;To Date&lt;/label&gt; &lt;input id="to_date" name="to_date" type="date"&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class="row"&gt; &lt;div class="span2 offset2"&gt; &lt;a href="#history" data-toggle="modal"&gt;View Details&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/br&gt; &lt;div class="row"&gt; &lt;div class="span3 offset2"&gt; &lt;label&gt;Comments&lt;/label&gt; &lt;textarea name="comments" rows="3"&gt;&lt;/textarea&gt; &lt;/div&gt; &lt;/div&gt; &lt;div&gt;&lt;?php echo validation_errors(); ?&gt;&lt;/div&gt; &lt;div class="line"&gt;&lt;/div&gt; &lt;div class="row"&gt; &lt;div class="span1 offset2"&gt; &lt;button type="submit" class="button-red"&gt;Apply&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php echo form_close(); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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