$checkUser1 = "SELECT * FROM users WHERE username='$username'";
$checkUser = $handler->prepare($checkUser1);
$checkUser->execute(array(':username' => $username));
$cU = ($checkUser->rowCount());
这不起作用,我不确定应该如何修复它。 这是一份PDO准备声明。
答案 0 :(得分:0)
此
$checkUser1 = "SELECT * FROM users WHERE username='$username'";
应该是
$checkUser1 = "SELECT * FROM users WHERE username=:username";
这样,您可以将变量绑定到参数,就像在execute数组中尝试一样。