违反完整性约束:1048 列 'ip' 不能为空(SQL:插入到 `users`(`name`、`steamid`、`avatar`、`token`、`ip`)
Integrity constraint violation: 1048 Column 'ip' cannot be null (SQL: insert into `users` (`name`, `steamid`, `avatar`, `token`, `ip`)
所以我正在尝试通过 Steam api 登录我的网站,然后弹出此错误 SQLSTATE[23000]:违反完整性约束:1048 列 'ip' 不能为空. SQL:
insert into `users` (`name`, `steamid`, `avatar`, `token`, `ip`)
我在 ubuntu 16.04 服务器 vmware
上使用 laravel php7.0 和 phpmyadmin
This is the structure of my database
And this is the users one where i have problems
如果你能帮助我,那将是非常感谢
代码:
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ip` text NOT NULL,
`steamid` varchar(17) NOT NULL,
`wagered` int(11) NOT NULL,
`wags` int(11) NOT NULL,
`wwags` int(11) NOT NULL,
`deps` int(11) NOT NULL,
`depamount` int(11) NOT NULL,
`withs` int(11) NOT NULL,
`withamount` int(11) NOT NULL,
`can_withdraw` int(11) NOT NULL DEFAULT '0',
`available` int(11) NOT NULL,
`aff` varchar(17) NOT NULL,
`affs` int(11) NOT NULL DEFAULT '0',
`affamount` int(11) NOT NULL,
`affcollected` int(11) NOT NULL,
`name` varchar(256) NOT NULL,
`balance` int(11) NOT NULL,
`rank` int(11) NOT NULL,
`steam_level` int(11) DEFAULT '-1',
`mute` int(11) NOT NULL,
`ban` int(11) NOT NULL,
`avatar` text NOT NULL,
`dailygift` int(11) NOT NULL,
`hourlygift` int(11) NOT NULL,
`redeemed_code` text NOT NULL,
`disabled_send` int(11) NOT NULL,
`disabled_withdraw` int(11) NOT NULL,
`token` varchar(128) NOT NULL,
`last` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
此列的定义是:
`ip` text NOT NULL,
这两者都非常庞大,因为 TEXT
旨在支持多达 64K 的数据,而且严格来说是“NOT NULL”,这意味着它 必须 被填充.
您可能想将其更改为:
ip VARCHAR(255) NULL,
您可以通过 Laravel 迁移来完成。
您必须给我们更多信息和相关代码部分,您应该避免外部链接。
然而,根据您 post 中的信息,您的请求中没有价值部分。
INSERT INTO `users` (`name`, `steamid`, `avatar`, `token`, `ip`) VALUES ($name, $steamid, $avatar, $token, $ip);
因为如您的 SQL 文件中所述,您强制您的值不为空。
所以我正在尝试通过 Steam api 登录我的网站,然后弹出此错误 SQLSTATE[23000]:违反完整性约束:1048 列 'ip' 不能为空. SQL:
insert into `users` (`name`, `steamid`, `avatar`, `token`, `ip`)
我在 ubuntu 16.04 服务器 vmware
上使用 laravel php7.0 和 phpmyadminThis is the structure of my database
And this is the users one where i have problems
如果你能帮助我,那将是非常感谢
代码:
CREATE TABLE `users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ip` text NOT NULL,
`steamid` varchar(17) NOT NULL,
`wagered` int(11) NOT NULL,
`wags` int(11) NOT NULL,
`wwags` int(11) NOT NULL,
`deps` int(11) NOT NULL,
`depamount` int(11) NOT NULL,
`withs` int(11) NOT NULL,
`withamount` int(11) NOT NULL,
`can_withdraw` int(11) NOT NULL DEFAULT '0',
`available` int(11) NOT NULL,
`aff` varchar(17) NOT NULL,
`affs` int(11) NOT NULL DEFAULT '0',
`affamount` int(11) NOT NULL,
`affcollected` int(11) NOT NULL,
`name` varchar(256) NOT NULL,
`balance` int(11) NOT NULL,
`rank` int(11) NOT NULL,
`steam_level` int(11) DEFAULT '-1',
`mute` int(11) NOT NULL,
`ban` int(11) NOT NULL,
`avatar` text NOT NULL,
`dailygift` int(11) NOT NULL,
`hourlygift` int(11) NOT NULL,
`redeemed_code` text NOT NULL,
`disabled_send` int(11) NOT NULL,
`disabled_withdraw` int(11) NOT NULL,
`token` varchar(128) NOT NULL,
`last` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
此列的定义是:
`ip` text NOT NULL,
这两者都非常庞大,因为 TEXT
旨在支持多达 64K 的数据,而且严格来说是“NOT NULL”,这意味着它 必须 被填充.
您可能想将其更改为:
ip VARCHAR(255) NULL,
您可以通过 Laravel 迁移来完成。
您必须给我们更多信息和相关代码部分,您应该避免外部链接。
然而,根据您 post 中的信息,您的请求中没有价值部分。
INSERT INTO `users` (`name`, `steamid`, `avatar`, `token`, `ip`) VALUES ($name, $steamid, $avatar, $token, $ip);
因为如您的 SQL 文件中所述,您强制您的值不为空。