简体   繁体   English

无效的日期时间格式:1366不正确的整数值:''对于第1行的列`facemock` .login_token` .id`

[英]Invalid datetime format: 1366 Incorrect integer value: '' for column `facemock`.`login_token`.`id` at row 1

I'm making a login module for a project, where I insert a token, that will be created in the code, into the database and while I'm trying to log in, I'll get this error: 我正在为一个项目创建一个登录模块,我在其中插入一个将在代码中创建的令牌进入数据库,当我尝试登录时,我会收到此错误:

Invalid datetime format: 1366 Incorrect integer value: '' for column facemock.login_token.id at row 1 in /Applications/XAMPP/xamppfiles/htdocs/FaceMock/classes/Database.php:12 无效的日期时间格式:1366不正确的整数值:''对于/Applications/XAMPP/xamppfiles/htdocs/FaceMock/classes/Database.php:12中第1行的列facemock.login_token.id

How to I fix this problem? 我该如何解决这个问题?

I tried to find a solution on the internet but i cant find something that can help my problem 我试图在互联网上找到解决方案,但我找不到可以帮助我解决问题的方法

I get the error with this line of code 我用这行代码得到了错误

Database::query('INSERT INTO login_token VALUES (\'\', :token, :user_id)', array(':token'=>sha1($token), ':user_id'=>$user_id));

When someone logs in, the token will be created, the token will be hashed to a 64 bit character and inserted into the database. 当有人登录时,将创建令牌,令牌将被散列为64位字符并插入数据库。 Then the user will be logged in. 然后用户将登录。

I am going to take a guess that you have a table with three columns: 我猜你有一个有三列的表:

id
token
user_id

where id is an auto-increment column. 其中id是自动增量列。 Your insert statement is missing the list of columns so MySQL will try to populate all the columns in the order they appear. 您的insert语句缺少列列表,因此MySQL将尝试按照它们出现的顺序填充所有列。 You tried to add an empty value using \\'\\' , but it is wrong because id is an integer and quotes are only for strings. 您尝试使用\\'\\'添加空值,但它是错误的,因为id是一个整数,引号仅用于字符串。 If the id should be generated pass null instead. 如果应该生成id而不是传递null eg 例如

Database::query('INSERT INTO login_token VALUES (null, :token, :user_id)', array(':token'=>sha1($token), ':user_id'=>$user_id));

or list the column names after table name without id 或列出没有id表名后的列名

Database::query('INSERT INTO login_token (token, user_id) VALUES (:token, :user_id)', array(':token'=>sha1($token), ':user_id'=>$user_id));

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SQLSTATE [22007]:无效的日期时间格式:1366错误的整数值:行1的列'infraction_id'的'[“ 1”,“ 3”,“ 66”,“ 68”]' - SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: '[“1”,“3”,“66”,“68”]' for column 'infraction_id' at row 1 无效的日期时间格式:1366不正确的整数值: - Invalid datetime format: 1366 Incorrect integer value: 日期时间格式无效:1366 integer 值不正确 - Invalid datetime format: 1366 Incorrect integer value MySQL,无效的日期时间格式:1366 不正确的 integer 值:“iRecipes”列的“”。“搜索”。“id”(php) - MySQL, Invalid datetime format: 1366 Incorrect integer value: '' for column `iRecipes`.`searches`.`id` (php) QLSTATE [22007]:无效的日期时间格式:1366 不正确的 integer 值 laravel - QLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value laravel Laravel 8:SQLSTATE[22007]:无效的日期时间格式:1366 不正确的 integer 值 - Laravel 8: SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value SQLSTATE [22007]:无效的日期时间格式:1366 不正确的 integer 值:“isVisible”列的“true” - SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'true' for column 'isVisible' SQLSTATE [22007]:无效的日期时间格式:1366不正确的整数值 - SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value SQLSTATE [22007]:无效的日期时间格式:1366 不正确的 integer 值:问题 - SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: problem SQLSTATE[22007]:无效的日期时间格式:1366 不正确的整数值:Laravel 中的“column_name” - SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'column_name' in Laravel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM