我尝试使用此代码检查数据库中是否存在3次电子邮件地址
$checkEmail = $_POST['email'];
$query = "SELECT email, count(*) $checkEmail FROM participanti GROUP BY email HAVING $checkEmail = 3";
$result = mysql_query($query) or die(mysql_error());
if ($row = mysql_num_rows($result)){
if ($row[$checkEmail] == 3) {
echo "NY";
}
else{
但是在我的网站上说
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@mail.com FROM participanti GROUP BY email HAVING [email protected] = 3' at line 1
最佳答案
$query = "SELECT email, count(*) as total
FROM participanti
WHERE email = '$checkEmail'
GROUP BY email
HAVING total = 3";
关于php - 如何使用php和mysql在数据库中查找电子邮件的重复条目?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18578375/