Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
606 views
in Technique[技术] by (71.8m points)

sql - #1366 - Incorrect integer value:MYsql

hi every one i have a problem in mysql

my table is

          CREATE TABLE IF NOT EXISTS `contactform` (
                  `contact_id` int(11) NOT NULL AUTO_INCREMENT,
                    `first_name` varchar(50) NOT NULL,
                  `addition` varchar(50) NOT NULL,
                     `surname` varchar(50) NOT NULL,
                  `Address` varchar(200) NOT NULL,
                   `postalcode` varchar(20) NOT NULL,
                        `city` varchar(50) NOT NULL,
                      `phone` varchar(20) NOT NULL,
                      `emailaddress` varchar(30) NOT NULL,
                           `dob` varchar(50) NOT NULL,
                               `howtoknow` varchar(50) NOT NULL,
                          `othersource` varchar(50) NOT NULL,
                             `orientationsession` varchar(20) NOT NULL,
                               `othersession` varchar(20) NOT NULL,
                                  `organisation` int(11) NOT NULL,
                                      `newsletter` int(2) NOT NULL,
                                      `iscomplete` int(11) NOT NULL,
                          `registrationdate` date NOT NULL,
                            PRIMARY KEY (`contact_id`)
                     ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=39 ;



             mysql>insert into contactform values('','abhi','sir','shukla','vbxcvb','342342','asdfasd','234234234','abhi@gmail.com','1999/5/16','via vrienden of familie','','19','20','6','1','1','2010-03-29')

i get following error. #1366 - Incorrect integer value: '' for column 'contact_id' at row 1

this query work fine on my local machine but give error on server

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Had the same problem with some legacy project. I didn't want to turn off strict mode globally, but also didn't want to go through all the code to fix it, so I disabled it only within that application by executing the following query once after the connection to the db is made:

SET sql_mode = ""

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...