title: Saving checkbox (boolean) values in mysql database with php
body: <p>I'm trying to save the checkbox value .. I'm doing a enrollment system with a checkbox form. It's function is to know if the student pass the requirement, so I assign it as a boolean type. It must save the value of '1' if the checked and '0' if unchecked. </p>
  
  <p>and the error are: </p>
  
  <pre><code>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '')' at line 2
  </code></pre>
  
  <p>and if I uncheck one of the requirement this is what happen:</p>
  
  <pre><code>Notice: Undefined index: brigada_form in C:\xampp2\htdocs\es\add_newstud.php on line 12
  Notice: Undefined index: two_picture in C:\xampp2\htdocs\es\add_newstud.php on line 18
  </code></pre>
  
  <p>I really need some help. Here is the code..</p>
  
  <p>Sample form: 1 set the value as '1' and the default value in my database is '0' </p>
  
  <pre><code>&lt;input type="checkbox" name="two_picture" id="two_picture" value="1" /&gt;
  </code></pre>
  
  <p>php code add_newstud.php</p>
  
  <pre><code>$requirement_id = $_POST['requirement_id'];     
  $enrollment_form = $_POST['enrollment_form'];
  $report_card = $_POST['report_card'];
  $brigada_form = $_POST['brigada_form'];
  $physical_inspection_form= $_POST['physical_inspection_form'];      
  $agreement_upon_enrollment = $_POST['agreement_upon_enrollment'];
  $nso = $_POST['nso'];
  $good_moral = $_POST['good_moral'];
  $one_picture = $_POST['one_picture'];       
  $two_picture = $_POST['two_picture'];
  
  $insert_req = "INSERT INTO es_req_newstud(requirement_id,enrollment_form,report_card,brigada_form,physical_inspection_form,agreement_upon_enrollment,nso,good_moral,1x1_picture,2x2_picture) `VALUES` ('$requirement_id','$enrollment_form','$report_card','$brigada_form','$physical_inspection_form','$agreement_upon_enrollment','$nso','$good_moral','$one_picture','$two_picture)";
  mysql_query($insert_req) or die(mysql_error());
  </code></pre>