0

sing up to php site Encountering an error

Incorrect integer value: '' for column 'id' at row 1

the data base code

  -- 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');
Isaac Bennetch
  • 11,830
  • 2
  • 32
  • 43
HAMED HNV
  • 11
  • 1

2 Answers2

2

In order to take advantage of the auto-incrementing capability of the column, do not supply a value for that column when inserting rows. The database will supply a value for you.

INSERT INTO user (name, lname, father, username, password, flag) VALUES ( 'yasha', 'asadpoor', 'akbari', 'yashaaa', '123456', '1'), ( '1', '2', '3', '4', '5', '1'), ( 'm', 'm', 'm', 'm', 'm', '1');

view this question.

Community
  • 1
  • 1
0

change insert statement to

INSERT INTO `user` (`id`, `name`, `lname`, `father`, `username`, `password`, `flag`) VALUES
(NULL,'yasha', 'asadpoor', 'akbari', 'yashaaa', '123456', '1'),
(NULL,'1', '2', '3', '4', '5', '1'),
(NULL,'m', 'm', 'm', 'm', 'm', '1');
Ram Sharma
  • 8,676
  • 7
  • 43
  • 56