我有一个SQL查询:PHP的mysqli - > bindValue SQL错误
if($stmt = $connection->prepare("INSERT INTO users(login, passwd, logged, register, last_login) VALUES(:login, :passwd, FALSE, NOW(), NULL")) {
$stmt->bindValue(':login', $login, PDO::PARAM_STR);
$stmt->bindValue(':passwd', md5($passwd), PDO::PARAM_STR);
$stmt->execute();
$stmt->close();
} else {
echo "query error <b>".$connection->error."</b><br>";
}
并返回该错误:
Connection error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ':login, :passwd, FALSE, NOW(), NULL' at line 1
我怎样才能解决呢?
我在Linux Fedora上使用MariaDB。在VALUES括号
你确保它与PDO连接,而不是mysqli的? – Qirel
是的,对不起,你是对的,我改变了标题。 –
'bindValue'是PDO,mysqli只有未命名的占位符。 – chris85