Jump to content

Having trouble echoing from database


beennn

Recommended Posts

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

$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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...