alexcrosson Posted October 1, 2006 Share Posted October 1, 2006 OKay i have my database set up like so:[b]id username password firstname lastname[/b]1 sample ck3949 John DOESomeone 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? Quote Link to comment Share on other sites More sharing options...
Barand Posted October 1, 2006 Share Posted October 1, 2006 $name = mysql_result($query, 0); Quote Link to comment Share on other sites More sharing options...
alexcrosson Posted October 1, 2006 Author Share Posted October 1, 2006 Thanks that did the trick. but do u think you could explain it? Quote Link to comment Share on other sites More sharing options...
Barand Posted October 1, 2006 Share Posted October 1, 2006 These can do that betterwww.php.net/mysql_resultwww.php.net/mysql_query Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.