我的php代碼如下。調用成員函數bindParam()什麼?
class Login {
public function logar($login, $senha){
$db = new Database();
try{
$conn = $db->connect();
$prepare = $conn->prepare("SELECT * FROM account WHERE Login = :login AND Passwd = :senha");
$prepare->bindParam(':login', $login, PDO::PARAM_STR);
$prepare->bindParam(':senha', $senha, PDO::PARAM_STR);
$prepare->execute();
$ranking = $prepare->rowCount();
if ($ranking >= 1){
return "<div class='n_ok' style='margin:9px 15px;'><p>Successfully.</p></div>";
}else{
return "<div class='n_error' style='margin:9px 15px;'><p>Usuario ou senha incorreta.</p></div>";
}
}catch(PDOException $e){
echo "Erro: ".$e->getMessage();
}
}
}
當我運行下面這樣的錯誤是發生
Fatal error: Call to a member function bindParam() on boolean in C:\AppServ\www\class\Login.class.php on line 9**
'prepare'方法返回false,似乎有一些問題與數據庫的連接。 –