Jump to content

PHP MYSQL get a users first name and surname from their user ID


dannyp100

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.