Php 从mysql数组中获取值并从字段中匹配
我遇到了一个小错误,我正试图从mysql获取这个值 数组并匹配字段中的值,但我得到一个错误 你能查一下我的密码吗Php 从mysql数组中获取值并从字段中匹配,php,mysql,sql,Php,Mysql,Sql,我遇到了一个小错误,我正试图从mysql获取这个值 数组并匹配字段中的值,但我得到一个错误 你能查一下我的密码吗 <?php if(isset($_POST['newsletter'])){ $email=$_POST['email']; $check=mysql_query("select email from newsletter"); while($row=mysql_fetch_array($query)) { if($row['email'])==$email){
<?php
if(isset($_POST['newsletter'])){
$email=$_POST['email'];
$check=mysql_query("select email from newsletter");
while($row=mysql_fetch_array($query))
{
if($row['email'])==$email){
echo "<script> alert('You are already Subscribed');</script>";
} else {
$sql_news=mysql_query("insert into newsletter(email) values('$email')");
echo "<script> alert('You are successfully Subscribed');</script>";
}}} ?>
更新此行,因为您使用$check值,所以在mysql获取中使用
while($row=mysql_fetch_array($query))
到
如果($row['email']…
)之后,)在那里做什么呢?
?不要使用mysql.*
函数,它们从PHP5.5开始就被弃用,在PHP7.0中被完全删除。使用或改用..改用PDO。我知道这是一个错误,但我仍然没有得到正确的结果这是您的$row=mysql\u fetch\u数组($query)$query?没关系,继续
while($row=mysql_fetch_array($check))