0

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
  • 2
    1. Please clarify what you are asking for. What is the table structure and what query are you trying to run against it? 2. You should go back and accept answers on your old questions. Commented Jan 29, 2010 at 7:58

1 Answer 1

1

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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.