gpt4 book ai didi

php - 检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行 '07:28:29)' 附近使用的正确语法

转载 作者:行者123 更新时间:2023-11-29 19:23:58 25 4
gpt4 key购买 nike

我想向 MySQL 插入记录,但它返回错误:

check the manual that corresponds to your MySQL server version for the right syntax to use near '07:28:29)' at line 1

我使用 PHP 来连接数据库。这是我写的:

$id = 353567452;
$firstname = "My_name";
$username = "@myusername";
$message_date = "2017-01-01 17:29:20";
$sql_check = "SELECT id, firstname, username, register_date FROM RJ_userino WHERE id=" . "$chat_id AND firstname=$firstname AND username=$username AND register_date=$message_date";
$sql_insert = "INSERT INTO RJ_userinfo (id, firstname, username, register_date) VALUES (" . "$chat_id, $firstname, $username, $message_date)";
$check = $db_req->query($sql_check);
if ($check->num_rows == 0){
$db_req->query($sql_insert);
}

这是我的专栏信息: enter image description here

问题出在哪里?

最佳答案

$message_date 应该是一个数字时间戳,例如。 1487230853

你可以使用php函数strtotime();

$message_date = strtotime("2017-01-01 17:29:20");

关于php - 检查与您的 MySQL 服务器版本相对应的手册,了解在第 1 行 '07:28:29)' 附近使用的正确语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42267667/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com