Page 1 of 1

Resource id #2 ???

Posted: Fri Apr 16, 2004 1:25 pm
by nshah
hey guys...

ok i have a database with ppls address fonenum faxnum email login and password

now when that user is logged in
it starts a session and assigns a variable for the users name
$_SESSION['user']
i know this variable contains the right information because when i use the echo statement it displays the user's name

however... when i want to display a specific row from my database on the page --with the following code

$result = mysql_query("SELECT * FROM register WHERE login ='$_SESSION['user']'");
echo $result;

--- the page displays "Resource id #2"

can anyone help?

Posted: Fri Apr 16, 2004 1:39 pm
by markl999
You are missing one of the mysql_fetch_ functions after the query.
See http://php.net/mysql_query and http://php.net/mysql_fetch_assoc for examples.

Posted: Fri Apr 16, 2004 2:28 pm
by malcolmboston
lol, we've all wondered this at some point.

basically you need to create an array for it,
continuing on your code

Code: Select all

$result = mysql_query("SELECT * FROM register WHERE login ='$_SESSION['user']'");
$array = mysql_fetch_array($result, MYSQL_ASSOC);
// now to print use $array['username'], $array['password'] etc etc
// you will need to make a loop to get all values
good luck