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 Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 9, 2013 Share Posted February 9, 2013 The problem is the extra comma. Quote Link to comment 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) Quote Link to comment 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! 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.