php - 尝试添加新用户,但出现此错误

标签 php mysql

登录 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/

相关文章:

mysql - 仅当有新图像要上传时才取消链接

mysql - 从每个月获取所有值,如果该月没有数据则置零

mysql - 适用于现有 MYSQL DB 的 Node REST API 框架

php - 为什么 "00:00:00"在 MYSQL 时间字段中被视为与 NULL 相同?

php - 帮助破解 Gruber 的自由 URL 正则表达式

在 cleardb 中执行和插入时出现 PHP PDO 错误

mysql - 使用 select 根据查询更新列

php - Yii addInCondition 与 float : How to ? 为什么 addInCondition ('column' , array(1.1, 1.3)) 不工作?

php - 维护良好的 PHP SMTP 身份验证类,无需发送电子邮件(登录测试)?

php - 如何从多行中选择并连接列值?