Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/apache-spark/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从mysql数组中获取值并从字段中匹配_Php_Mysql_Sql - Fatal编程技术网

Php 从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){

我遇到了一个小错误,我正试图从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){
    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))