dannyp100 Posted February 9, 2013 Author Share Posted February 9, 2013 This is what i get when i debugg it #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM gn_messages INNER JOIN gn_users to_user ON to_user.user_id = gn_messages.m' at line 4 Link to comment https://forums.phpfreaks.com/topic/274214-php-mysql-get-a-users-first-name-and-surname-from-their-user-id/page/2/#findComment-1411295 Share on other sites More sharing options...
Jessica Posted February 9, 2013 Share Posted February 9, 2013 Put the SQL in a string and echo it, just like the example. Link to comment https://forums.phpfreaks.com/topic/274214-php-mysql-get-a-users-first-name-and-surname-from-their-user-id/page/2/#findComment-1411298 Share on other sites More sharing options...
Jessica Posted February 9, 2013 Share Posted February 9, 2013 The problem is the extra comma. Link to comment https://forums.phpfreaks.com/topic/274214-php-mysql-get-a-users-first-name-and-surname-from-their-user-id/page/2/#findComment-1411299 Share on other sites More sharing options...
dannyp100 Posted February 9, 2013 Author Share Posted February 9, 2013 SELECT gn_messages.*, CONCAT(to_user.userFirstName, ' ', to_user.userSurname) AS to_full_name, CONCAT(from_user.userFirstName, ' ', from_user.userSurname) AS from_full_name FROM gn_messages INNER JOIN gn_users to_user ON to_user.userID = gn_messages.messageTo INNER JOIN gn_users from_user ON from_user.userID =gn_messages.messageFrom WHERE messageTo = $messageTo AND messageDeleted = '0' ORDER BY messageDate DESC This query is working now but not returning a name, still only the userID? I have return it as (return->messageFrom) Link to comment https://forums.phpfreaks.com/topic/274214-php-mysql-get-a-users-first-name-and-surname-from-their-user-id/page/2/#findComment-1411303 Share on other sites More sharing options...
dannyp100 Posted February 9, 2013 Author Share Posted February 9, 2013 succes it works!!! as i returned (from_full_name) thankyou! Link to comment https://forums.phpfreaks.com/topic/274214-php-mysql-get-a-users-first-name-and-surname-from-their-user-id/page/2/#findComment-1411306 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.