Php PDO查询的MySQL语法错误

Php PDO查询的MySQL语法错误,php,pdo,Php,Pdo,我正在尝试将_UNIXTIME中的mysql函数与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-

我正在尝试将_UNIXTIME中的mysql函数与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

删除
你在
WHERE
之前的字符,WHERE

这可能与你的
WHERE
子句前面的逗号有关吗?我添加了错误消息,让大家冷静下来,我只是太早按了发布按钮:)@palardiam该死,我瞎了:/问题解决了。。。我认为这是另一种类型的问题,因为我是PDO新手…@someone:通常当语法错误发生时,请直接查看MySQL告诉您错误发生的地方。这通常是它所在的地方。这与PDO无关。请在CLI中使用/播放MySQL。