I have a MySQL query to echo a result from a single cell in a column named 'status' based on an email address in column 'email'. The email variable is passed from a previous page but the query does not return the cell value in the 'status' column defined by the email address; the code snippet is;
mysql_select_db("$dbname", $link) || die("Couldn't open db: $dbname. Error if any was: ".mysql_error() );
$result = mysql_query("SELECT status FROM users WHERE email='$email'");
$row = mysql_fetch_array($result);
$status = $row["status"];
echo $dbname; //test database connect
echo $email; //check variable was passed
Can someone identify what I'm doing wrong and help in correcting the code to return the cell value in the 'status' column based on the email address variable?