phpmyadmin,使用提供的表单工具插入记录时会出现错误

时间:2012-12-20 00:33:19

标签: sql phpmyadmin

使用phpmyadmin中的工具插入记录时,如果它不应放置任何内容或''null,则会放入0。生成sql代码的phpmyadmin上有错误。

错误(更合适的是警告)是:

插入1行。 插入的行ID:17 警告:#1366不正确的整数值:''对于第1行的'userNo'列

phpmyadmin生成的sql是:

INSERT INTO plenty_of_singles.user (
    userNo ,
    username ,
    password ,
    email ,
    gender ,
    age ,
    country ,
    area ,
    city ,
    relocate ,
    height ,
    weight ,
    overview
)
VALUES (
'', 'girl101', MD5( 'weebling' ) , 'girl101@hotmail.com', 'female', '18', 'UK', 'England', 'Manchester', 'yes', '5''8"', '50 kg', 'Genuine girl who would like to find the right person.'
);

知道一个解决方案以及是否有其他人遇到过这个问题会很好。

mysql版本5.0.10。

表的SQL代码:

CREATE TABLE `user` (  
`userNo` int(11) unsigned NOT NULL AUTO_INCREMENT,  
`username` varchar(16) NOT NULL COMMENT 'username, alphanumeric 16 characters long.',  `password` varchar(32) NOT NULL COMMENT 'password alphanumeric 16 characters long , but when encrypted using MD5 it becomes a hexidecimal number 32 digits long',  
`email` varchar(40) NOT NULL COMMENT 'email is an alphanumeric 40 characters long',  `gender` varchar(6) NOT NULL COMMENT 'gender is alphanumeric and will always be male or female',  
`age` int(3) NOT NULL COMMENT 'age will be an integer 3 digits long',  
`country` varchar(35) NOT NULL COMMENT 'country is alphabetic 35 characters long',  
`area` varchar(35) NOT NULL COMMENT 'area is alphabetic 35 characters long',  
`city` varchar(35) NOT NULL COMMENT 'city is alphabetic 35 characters long',  
`relocate` varchar(3) NOT NULL COMMENT 'relocate is a alphabetic 3 characters long. possible values are yes or no',  
`height` varchar(15) NOT NULL COMMENT 'height is alphanumeric and 15 chracters long.',  `weight` varchar(15) NOT NULL COMMENT 'wieight is alphanumeric and 15 chracters long.',  `overview` varchar(255) NOT NULL,  
PRIMARY KEY (`userNo`),  
UNIQUE KEY `username` (`username`)) 
ENGINE=InnoDB AUTO_INCREMENT=23 DEFAULT CHARSET=latin1

1 个答案:

答案 0 :(得分:1)

不要给userNo字段赋值,请使用此查询来自动增加字段

          INSERT INTO plenty_of_singles.user (

username ,
password ,
email ,
gender ,
age ,
country ,
area ,
city ,
relocate ,
height ,
weight ,
overview
)
VALUES (
  'girl101', MD5( 'weebling' ) , 'girl101@hotmail.com', 'female', '18', 'UK','England', 'Manchester', 'yes', '5''8"', '50 kg', 'Genuine girl who would like to find the right person.'
  );