rajanikant
rajanikant

Reputation: 171

#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','[email protected]','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

Upvotes: 17

Views: 116908

Answers (7)

aserapig
aserapig

Reputation: 1

If you are importing - make sure your CSV/TXT file is UTF-8 WITHOUT the BOM - the BOM will pass characters that are not intgers and MySQL will think you are importing that into the first field...

Upvotes: 0

In mysql console, try this:

SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

Upvotes: 0

sroes
sroes

Reputation: 15053

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 = ""

Upvotes: 24

Alexander Wenzel
Alexander Wenzel

Reputation: 121

Try to find following line in my.cnf/my.ini:

sql-mode=”STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION”

Now comment it out with # and restart your mysql server.

Upvotes: 10

Frank Heikens
Frank Heikens

Reputation: 126991

'' is an empty string, you want a integer, but this integer is created by the database. Drop the columnname in the INSERT and don't insert any value.

Upvotes: 6

codaddict
codaddict

Reputation: 454960

Try using NULL instead of '' for contact_id in

insert into contactform values(NULL,......

Upvotes: 21

Amy B
Amy B

Reputation: 17977

'' is not an integer, is it?

Also, that is some seriously weird indentation.

Upvotes: 0

Related Questions