0

I detect a problem in my database about length column. So I have a database in phpmyadmin in a mac and I import it to a database in phpmyadmin in windows machine.

So, I have a column named startHour and it's a varchar(5), and from form the value is 10:30:00 with 8 length but in mac it inserts 10:30 and in windows it returns error:

String data, right truncated: 1406 Data too long for column 'startHour' 

How can I solve that? Should be an option in second database?

I know that if I send 8 characters the field should has 8 but I don't need that in database but I want to show the seconds to user.

Thank you

Shadow
  • 33,525
  • 10
  • 51
  • 64
user3242861
  • 1,839
  • 12
  • 48
  • 93
  • Alter your table and make the column varchar(8). – LMC Jan 30 '18 at 16:22
  • 1
    1) use the time data type to store times, not varchar. 2) you knowingly insert incorrect data in your db? Truncate it in your application code or make the field big enough. 3) you should enable the strict mode on your mac mysql instance as well. – Shadow Jan 30 '18 at 16:24
  • 1
    I found what was the problem. In database connection setting I set parameter strict => 'false' and works. – user3242861 Jan 30 '18 at 16:34

0 Answers0