ユーザーが存在するかどうかを確認するためにフォームに渡された値とデータベースの値を照合しようとすると、次のエラーが発生します。キャッチ可能な致命的なエラー:クラスPDOStatementのオブジェクトを文字列に変換できません
Catchable fatal error: Object of class PDOStatement could not be converted to string
これは私が使用しているコードです:
//Check users login details
function match_login($username, $password){
//If the button has been clicked get the variables
try{
$dbh = new PDO("mysql:host=localhost;dbname=mjbox","root", "usbw");
} catch(PDOException $e) {
echo $e->getMessage();
}
$stmt = $dbh->prepare("SELECT * FROM mjbox WHERE username=? AND password=?");
$stmt->bindParam(1, $username);
$stmt->bindParam(2, $password);
$stmt->execute();
$result = mysql_query($stmt);
if(mysql_num_rows($result) > 0){
echo 'There is a match!';
}else{
echo 'nooooo';
}
}
PDOを使用している場合は、mysql_ *を使用しないでください... – Esailija