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

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)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.