我正在尝试将 mysql 函数 FROM_UNIXTIME 与 PDO 一起使用:
$sth = $dbh->prepare("UPDATE ".DB_PREFIX."_logins SET num_of_trys = num_trys-1,
last_try = FROM_UNIXTIME(:last_try), WHERE username = :username
OR ip = :ip");
$sth->bindParam(':ip', $ip);
$sth->bindParam(':username', $user);
$sth->bindParam(':last_try', $lst);
$sth->execute();
但我收到错误消息。这样做的正确方法是什么?
这是错误消息:
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42000]:
Syntax error or access violation: 1064 You have an error
in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near
'WHERE username = 'sadas' OR ip = '1834871734'' at line 1'
in /pathtofile/acc_functions.php:72 Stack trace: #0
/pathtofile/acc_functions.php(72): PDOStatement->execute() #1
/pathtofile/login.php(44): check_login_attempts(1834871734,
1343941422, 'sadas') #2 {main} thrown in
/pathtofile/acc_functions.php on line 72