0

From my application registration form, I 'm trying to insert check box value into mysql table but it throw an error 1406 Data too long for column . The value of tick box is 0 or 1. and my table structure is, create table test( checkbox_response bit(1))...

I had gone through something and I found the solution for this problem. The solution is, I just changed my sql-mode SET @ @global.sql_mode = ''... After the proper insertion was happened.

Though My Datatype size is fit for check box value, Why it throws an 1406 error?

user3113732
  • 95
  • 1
  • 3
  • 13

1 Answers1

0

Please use "TINYINT(1)" instead of "Bit(1)".

adarsh hota
  • 327
  • 11
  • 23
  • Thanks for your reply Adarsh... Actually The signed range of TINYINT is 0 to 255 and for BIT is 0 to 64. I really wanted to know Why this has been happened, Though Check box value come under the datatype range. would you please explain that? – user3113732 Jan 07 '15 at 08:37
  • [refer this] http://stackoverflow.com/questions/289727/which-mysql-datatype-to-use-for-storing-boolean-values – adarsh hota Jan 07 '15 at 09:22