php - Setting TINYINT value fails but MySQL Error prints nothing -


checking previous questions on use of tinyint values, realize facing unique case hence question. trying insert values table 'faculty' tinyint field using checkbox , seperate values 'admin' table @ same time. insert works 'admin' table doesn't 'faculty' , mysql error prints nothing.mysql error prints nothing

php script ---

<?php   if (isset($_post['submit'])) {     $staff_id = $_post["staff_id"];     $first_name = $_post["first_name"];     $last_name = $_post["last_name"];     $preschool = isset($_post["preschool"]) ? 1 : 0;     $year1 = isset($_post["year1"]) ? 1 : 0;     $year2 = isset($_post["year2"]) ? 1 : 0;     $year3 = isset($_post["year3"]) ? 1 : 0;     $year4 = isset($_post["year4"]) ? 1 : 0;     $year5 = isset($_post["year5"]) ? 1 : 0;     $year6 = isset($_post["year6"]) ? 1 : 0;      $username = $_post["username"];     $password = $_post["password"];     $role = "teacher";      $sql  = "insert faculty (staff_id, firstname, lastname, preschool, year1, year2, year3, year4, year5, year6)";     $sql .= " values ({$staff_id}, '{$first_name}', '{$last_name}', {$preschool}, {$year1}, {$year2}, {$year3}, {$year4}, {$year5}, {$year6})";     $result = mysqli_query($connection, $sql);      $sql2  = "insert admin (staff_id, first_name, last_name, role, username, password)";     $sql2 .= " values ({$staff_id}, '{$first_name}', '{$last_name}', '{$role}', '{$username}', '{$password}')";     $result2 = mysqli_query($connection, $sql2);      //if (!$result) {         //echo 'mysql error: ' . mysqli_error($connection);         //exit;     //}      if ($result && $result2) {         $_session["message"] = "new faculty added successfully.";         redirect_to("faculty.php");     } else {         $_session["message"] = "operation failed.";         redirect_to("new_faculty.php");     } } ?> 

html ---

<div class="checkbox">     <label>preschool </label> &nbsp <input type="checkbox" name="preschool">     <label>year 1 </label> &nbsp <input type="checkbox" name="year1">     <label>year 2 </label> &nbsp <input type="checkbox" name="year2">     <label>year 3 </label> &nbsp <input type="checkbox" name="year3">     <label>year 4 </label> &nbsp <input type="checkbox" name="year4">     <label>year 5 </label> &nbsp <input type="checkbox" name="year5">     <label>year 6 </label> &nbsp <input type="checkbox" name="year6"> </div> 

what's wrong code?


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -