登录 php 网站遇到错误
Incorrect integer value: '' for column 'id' at row 1
数据库代码
-- Table structure for table `user`
CREATE TABLE `user` (
`id` int(11) NOT NULL auto_increment,
`name` text NOT NULL,
`lname` text NOT NULL,
`father` text NOT NULL,
`username` text NOT NULL,
`password` text NOT NULL,
`flag` enum('0','1') NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;
--
-- Dumping data for table `user`
--
INSERT INTO `user` (`id`, `name`, `lname`, `father`, `username`, `password`, `flag`) VALUES
(1, 'yasha', 'asadpoor', 'akbari', 'yashaaa', '123456', '1'),
(2, '1', '2', '3', '4', '5', '1'),
(3, 'm', 'm', 'm', 'm', 'm', '1');
最佳答案
为了利用列的自动递增功能,插入行时不要为该列提供值。数据库将为您提供一个值。
INSERT INTO <code>user</code> (<code>name</code>, <code>lname</code>, <code>father</code>, <code>username</code>, <code>password</code>, <code>flag</code>) VALUES
( 'yasha', 'asadpoor', 'akbari', 'yashaaa', '123456', '1'),
( '1', '2', '3', '4', '5', '1'),
( 'm', 'm', 'm', 'm', 'm', '1');
查看此 question 。
关于php - 尝试添加新用户,但出现此错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27188650/