1

使用 phpmyadmin 中的工具插入记录''时,它会在不应该放置任何东西或 anull0. 生成 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
4

1 回答 1

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.'
  );
于 2012-12-20T04:05:10.407 回答