sted999 Posted April 3, 2009 Share Posted April 3, 2009 Hiya all. Ive been searching on the internet and it appears there are several ways to do this. What i am trying to is search the database from a given variable (loginName) and then get the email from the same record. But it is not finding any data? Can anybody see what I am doing wrong? Thanks. <?php $username=($_POST['username']); echo "User selected = $username"; include ('connect.php'); mysql_select_db("a6188092") or die(mysql_error()); $sql = ("SELECT loginName, email, firstName FROM Member WHERE loginName='$userName'"); $result = mysql_query($sql); if (!$result) { echo "Could not run query ($sql) from database: " . mysql_error(); exit; } if (mysql_num_rows($result) == 0) { echo "No results found"; exit; } while ($row = mysql_fetch_assoc($result)) { echo $row["loginName"]; echo $row["email"]; echo $row["firstName"]; } mysql_free_result($result); ?> Quote Link to comment Share on other sites More sharing options...
ober Posted April 3, 2009 Share Posted April 3, 2009 Your variable is $username. Your query is using $userName. $username != $userName. Variables are case sensitive. Quote Link to comment Share on other sites More sharing options...
sted999 Posted April 3, 2009 Author Share Posted April 3, 2009 Thanks! I feel such an idiot for not noticing that. I have been at it since 8 this morning tho. Cheers mate, top man Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.