1

I got stuck in minor error on which I am trying to fetch the value from mysql.

Array and matching the value from field, but I am getting an error.

Can you please check my code:

<?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>"; 
 }}} ?>

Thanks in advance!!!

timiTao
  • 1,417
  • 3
  • 20
  • 34

1 Answers1

1

update this line cause you use $check value so in mysql fetch use this

while($row=mysql_fetch_array($query))

to

while($row=mysql_fetch_array($check))
Shafiqul Islam
  • 5,570
  • 2
  • 34
  • 43