beennn Posted October 19, 2012 Share Posted October 19, 2012 At the top of my file I have: session_start();$Email = $_SESSION['email_address']; mysql_connect ("localhost","root" ,"####") or die ('error: ' . mysql_error()); mysql_select_db ("accounts"); $selectProject = mysql_query("SELECT * FROM $Email") or die(mysql_error()); while($row = mysql_fetch_array($selectProject)) { $Name = $row ['Name']; } Further down the file I'm trying to echo $Name, but nothings appearing, and I'm not getting any errors <?php echo ($Name); ?> Any idea where I'm going wrong? Link to comment Share on other sites More sharing options...
justsomeguy Posted October 19, 2012 Share Posted October 19, 2012 What is $Email? If that is an email address, do you have tables in your database named after email addresses? I don't think those would be legal names. Link to comment Share on other sites More sharing options...
beennn Posted October 19, 2012 Author Share Posted October 19, 2012 $Email is just letters, no symbols. It's not actually an email address, for testing, $Email's value is "Test" in the database. It only just crossed my mind to try it with "Test" instead of $Email, which does work. I know $Email is holding "Test", so is "SELECT * FROM $Email" the wrong way to write it? Link to comment Share on other sites More sharing options...
justsomeguy Posted October 19, 2012 Share Posted October 19, 2012 It's fine to write it like that. It sounds like $Email doesn't contain what you think it does. Print out that query if you want to verify it. Also note that $Name is going to contain the value from the last row in that table, in whatever order the database returns them. Maybe that value is blank. Link to comment Share on other sites More sharing options...
beennn Posted October 19, 2012 Author Share Posted October 19, 2012 Aha! Thank you very much, it was Also note that $Name is going to contain the value from the last row in that table, in whatever order the database returns them. Maybe that value is blank. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now