If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Calling data from the database

Hello, I am new to PHP and have been working on a site which I would like to set up some user profiles. I have currently been toying around with the profile page and in order to get better equipped I have been trying to call different information to the tables on the profile page.

I have not had much success. The only success I have is calling the username to the page with this,

if ($_SESSION['username'])
{
echo "You are logged in as ".$_SESSION['username'];

I have been trying to call the users email to the page with similar tags and tags I have found on the internet with no luck.

Does anyone have a general rule of commands or some advice on how I can accomplish tasks as simple as calling information from the DB?

I am at some point trying to set up a gallery for users to upload pictures to there profile and I really need some guidance on how to get there.

Well...the information will only be in $_SESSION if your code put it there. So if you want to access it that way, you'll probably need to modify your login processing to add that data element to the $_SESSION array. Otherwise, you'll need to explicitly query the database for that info in any situation where you need it.

"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation

After this executes it post the most recent person who has registered on the sites information instead of the person who just loged in. I need this to show the persons information who is logged in. Thanks for your help...

How does it know the session username with out me defining any variables on this page.
When I change the $_SESSION['username']; to $_SESSION['email']; I get a syntax error. How come it knows the username and works just fine on every page I include this file on but when I use email there instead it does not know it???

The undefined index problem generally means that no information is being assigned to the variables, possible a problem with your posted data. Try echoing out the posted data to see if they have any values.

As for the while loop, what you have is incorrect but I also missed a closing bracket in my original code. It should be:

That is what I said before, echo out the data you are fetching from your database to ensure you are getting it and the data is correct. So as a temporary measure, in your while loop, comment out assigning to the sessions and echo each row individually.