rezurrection Posted September 28, 2010 Share Posted September 28, 2010 Hi, I am new to php and am trying to develop a back end login system. I am having problems trying to get it to display the users first and last names when they login. I was wondering if anyone could help with this. The MySQL version on my server is 5.0.51a. The database has two tables for the users, fdologins and fdomemberdetails. The fdlogins table looks like this: | id | username | password | ref | email | location | postcode | The fdomemberdetails table looks like this: | id | memberid | firstname | surname | address1 | adress2 | adress3 | postcode | telephone | The 'id' in fdlogins is the same as the 'memberid' in fdomemberdetails. When a user login a session is created with the following: SESS_LOGGEDIN = 1 SESS_USERNAME - takes the username SESS_USERID - takes the memberid I have tried the following MySQL query to no avail. <?php$username = mysql_query("SELECT fdomemberdetails.firstname, fdomemberdetails.surname FROM fdomemberdetails INNER JOIN fdologins ON fdologins.username = '{$_SESSION['SESS_USERNAME']}', WHERE fdologins.id = fdomemberdetails.memberid ");?> <?phpwhile ($row= mysql_fetch_array($username)){echo $row["firstname"] ; echo $row["surname"] ; }?> I would be very grateful for any help you can provide on this. If you require any additional information please let me know. Thank you for your help. Regards, Andy Quote Link to comment https://forums.phpfreaks.com/topic/214622-php-mysql-query-help/ Share on other sites More sharing options...
kickstart Posted September 28, 2010 Share Posted September 28, 2010 Hi You appear to have the WHERE clause and ON clause mixed up (although they might manage to work like that) <?php $username = mysql_query(" SELECT fdomemberdetails.firstname, fdomemberdetails.surname FROM fdomemberdetails INNER JOIN fdologins ON fdologins.id = fdomemberdetails.memberid WHERE fdologins.username = '".$_SESSION['SESS_USERNAME']."'"); ?> Give that a try. All the best Keith Quote Link to comment https://forums.phpfreaks.com/topic/214622-php-mysql-query-help/#findComment-1116757 Share on other sites More sharing options...
rezurrection Posted September 28, 2010 Author Share Posted September 28, 2010 Thank you for your reply Keith. I managed to get it to work. Think I was trying to be over complicated with the query. This is what I used to get it to work. $fullname = mysql_query("select fdomemberdetails.firstname, fdomemberdetails.surnamefrom fdomemberdetailswhere fdomemberdetails.memberid = '{$_SESSION['SESS_USERID']}'limit 1"); Once again thank you for your time. Regards, Andy Quote Link to comment https://forums.phpfreaks.com/topic/214622-php-mysql-query-help/#findComment-1116759 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.