#1366 - 不正确的整数值:MYsql
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2536199/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
#1366 - Incorrect integer value:MYsql
提问by rajanikant
hi every one i have a problem in mysql
大家好,我在 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
我收到以下错误。#1366 - 不正确的整数值:第 1 行的“contact_id”列的“”
this query work fine on my local machine but give error on server
这个查询在我的本地机器上工作正常,但在服务器上出错
回答by codaddict
Try using NULL
instead of ''
for contact_id
in
尝试使用NULL
代替''
for contact_id
in
insert into contactform values(NULL,......
回答by sroes
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 = ""
回答by Alexander Wenzel
Try to find following line in my.cnf/my.ini:
尝试在 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.
现在用 # 注释掉它并重新启动你的 mysql 服务器。
回答by Frank Heikens
'' 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.
'' 是一个空字符串,你想要一个整数,但是这个整数是由数据库创建的。删除 INSERT 中的列名,不要插入任何值。
回答by Amy B
''
is not an integer, is it?
''
不是整数,是吗?
Also, that is some seriously weird indentation.
此外,这是一些非常奇怪的缩进。
回答by R?mulo Z. C. Cunha
In mysql console, try this:
在 mysql 控制台中,试试这个:
SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
回答by Tom Hoffmann V.
I had the same issue, but in my case, I only needed to select the A.I. (Auto-Increment) button in my id section on my DataBase table.
我遇到了同样的问题,但就我而言,我只需要在我的数据库表的 id 部分中选择 AI(自动增量)按钮。