您好,我试图使用 PDO 实现功能,但出现错误(PDO 的新功能)这是我的代码
function mail_id($mail){
global $host, $dbname, $user, $pass;
$DBH = new PDO("mysql:host=$host;dbname=$dbname", $user, $pass);
$STH = $DBH->query("select count(from) from messages where from = '$mail'");
$STH->setFetchMode(PDO::FETCH_ASSOC);
$row = $STH->fetch();
return $row;
}
我想从 FROM 数行,这是我正在尝试的输出
$mail=mail_id($userid);
if (0<count($mail['to_viewed'])) {echo "green";} else {echo "gray";}
这是错误
Call to a member function setFetchMode() on a non-object
请帮助谢谢