我正在尝试将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
答案 0 :(得分:6)
删除,
之前的WHERE
字符。