Does anyone see an issue with the following IF statement... I sure can't yet it doesn't work!

VARIABLES:
$CHECK = A returned value from the database either "y" or "n", the value is returned successfully so I know that is not the issue here.

There is no error message returned, the IF statement simply refuses to work.

$check = mysql_fetch_row($resultX);
if($check == "y"){
}elseif($check == "n"){
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=main.php\">";
}

Recommended Answers

All 4 Replies

I would simplify if there are only two choices:

$check = mysql_fetch_row($resultX);
          if($check == "y"){
          }else{
           echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=main.php\">";
          }

Does anyone see an issue with the following IF statement... I sure can't yet it doesn't work!

VARIABLES:
$CHECK = A returned value from the database either "y" or "n", the value is returned successfully so I know that is not the issue here.

There is no error message returned, the IF statement simply refuses to work.

$check = mysql_fetch_row($resultX);
if($check == "y"){
}elseif($check == "n"){
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=main.php\">";
}

First check what is inside your $resultX

var_dump(mysql_fetch_row($query));

or try posting your query also so that someone could help you
:)

danishbacker is right. mysql_fetch_row returns an array, so you should use $check[0] (probably, if it is the first or only column in your query result).

offtopic to the op, but

$check = mysql_fetch_row($resultX);
if(!$check == "y"){header("Location: main.php");
exit;}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.