tags:

views:

179

answers:

1

how to add checkbox values in mysql database?Please help I always get this error when I incorporate checkbox in my form. Does the data type have to be changed in mysql.

Error: 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 'check (TRANSPORT, X, Y) VALUES ('vsf', 'car', 'fa')' at line 1

+1  A: 

For a checkbox use a bool/tinyint(1) column. HTML checkboxes only return a value if they are checked. Here's what I usually do:

HTML:

<form method="post">
   <input type="checkbox" name="myCheckbox">
   <input type="submit">
</form>

PHP:

$myCheckbox = isset($myCheckbox);
Zanthrax