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? Link to comment https://forums.phpfreaks.com/topic/22682-query-question/ Share on other sites More sharing options...
Barand Posted October 1, 2006 Share Posted October 1, 2006 $name = mysql_result($query, 0); Link to comment https://forums.phpfreaks.com/topic/22682-query-question/#findComment-101987 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? Link to comment https://forums.phpfreaks.com/topic/22682-query-question/#findComment-101999 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 Link to comment https://forums.phpfreaks.com/topic/22682-query-question/#findComment-102021 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.