Piyush Seofaceup
Piyush Seofaceup

Reputation: 61

Fetching the value from mysql array and match from the field

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!!!

Upvotes: 1

Views: 35

Answers (1)

Shafiqul Islam
Shafiqul Islam

Reputation: 5690

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))

Upvotes: 1

Related Questions