Jump to content

Archived

This topic is now archived and is closed to further replies.

alexcrosson

Query Question

Recommended Posts

OKay i have my database set up like so:

[b]id        username              password                firstname              lastname[/b]
1          sample                    ck3949                John                      DOE

Someone can login and it checks weather its the right password and then redirects them to a diferent page. On that page I want to have a message Saying "Welcome John", meaning that i need to pull the firstname out of the row of the user that is logged in.

Heres my code:

[code]$query = mysql_query("SELECT firstname FROM users WHERE username='$user'") or die ("Can't execute: " . mysql_error());
$name = $query
?>
  <h1>Welcome <? print $name; ?>,</h1>[/code]

And i don't get any errors but my output is:

[b]Welcome Resource id #4[/b]

Any idea?

Share this post


Link to post
Share on other sites
These can do that better

www.php.net/mysql_result

www.php.net/mysql_query

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.