Sorry about not replying sooner - I had to do some urgent work!
You're main problem is your field names - you can't have "from" as a field name, because it is an SQL reserved word.
If you think of a query:
SELECT message_id, user_id
FROM messages
WHERE message_id=1;
You already use the word FROM within the query to begin describing which tables to use. If you try and include a fieldname called "from" into the query, it will no longer make any sense. For example:
SELECT message_id, from, user_id
FROM messages
WHERE message_id=1;
Prefix your fieldnames with a letter (e.g. "m" for the messages table, and "u" for the users table), to avoid any confusion. This will probably be enough for your queries to run correctly.