尝试将数据库上的值与表单中传递的值进行匹配以检查用户是否存在时,出现以下错误。
可捕获的致命错误:PDOStatement 类的对象无法转换为字符串
这是我正在使用的代码:
//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';
}
}