MySQL Query result

Hello Experts;

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;

<?php
session_start();
include_once("config.php");
$email=$_SESSION["email"];

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
mysql_close($link);
?>

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?

Thank you,
visionetv
visionetvAsked:
Who is Participating?
 
visionetvAuthor Commented:
Dave;

Thanks for pointing out a silly mistake... tough to know the code is working when I didn't echo the result.

Thank,
visoinetv
0
 
Dave BaldwinFixer of ProblemsCommented:
The code looks ok assuming you haven't misspelled anything.  Are you getting an error message or anything?  I don't see that you are echoing $status so you can check it.
0
 
visionetvAuthor Commented:
The 100 points should be awared to Dave Baldwin.
 visionetv
0
 
visionetvAuthor Commented:
Overlooked echoing result from query to confirm php code functioning properly
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.