尝试通过pdo检查用户是否存在
$wantedusrnm = $_POST['new-usrnm'];
$userExist1 = "SELECT * FROM users WHERE username=:wantedusrnm";
$userExist = $handler->prepare($userExist1);
$userExist->execute(array(':username' => $wantedusrnm));
$userExist = ($userExist->rowCount());
由于某种原因它出错了,不知道为什么,有什么原因?
答案 0 :(得分:0)
变化:
$userExist->execute(array(':username' => $wantedusrnm));
要:
$userExist->execute(array(':wantedusrnm' => $wantedusrnm));
因为,在您的查询中,您已获得:wantedusrnm
,但在您的执行阵列中,您已获得:username
。