Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MySQL Query result

Posted on 2012-03-30
4
Medium Priority
?
305 Views
Last Modified: 2012-04-04
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
0
Comment
Question by:visionetv
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 37788550
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
 

Accepted Solution

by:
visionetv earned 0 total points
ID: 37788998
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
 

Author Comment

by:visionetv
ID: 37789040
The 100 points should be awared to Dave Baldwin.
 visionetv
0
 

Author Closing Comment

by:visionetv
ID: 37805196
Overlooked echoing result from query to confirm php code functioning properly
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses how to create an extensible mechanism for linked drop downs.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question