我有一点问题:
public function is_present($Idarticle,$email){
$query=" SELECT * FROM envmail WHERE mail_env='$email' AND id_article='$Idarticle' ";
return mysql_query($query,$this->connection);
}
if($alert->is_present($idarticle,$email)){
echo "yes";
}
else echo "no";
mail_env是一个varchar,id_article是一个int。 我一直都是。
答案 0 :(得分:0)
将您的代码更改为此。
public function is_present($Idarticle,$email){
$query=" SELECT * FROM envmail WHERE mail_env='$email' AND id_article='$Idarticle' ";
$result = mysql_query($query,$this->connection);
//return mysql_num_rows($result);
// Update as suggested by @Mark
return mysql_num_rows($result) !== 0
}
//if($alert->is_present($idarticle,$email) > 0 ){
// Updated
if($alert->is_present($idarticle,$email)){
echo "yes";
}
else echo "no";
答案 1 :(得分:0)
public function is_present($Idarticle,$email){
$query=" SELECT * FROM envmail WHERE mail_env='".$email."' AND id_article='".$Idarticle."' ";
$result = mysql_query($query,$this->connection);
return mysql_num_rows($result);
}
if($alert->is_present($idarticle,$email) > 0 ){
echo "yes";
}
else echo "no";