Reputation: 55
I am working on a PM system and I have everything down, besides figuring out how the correct person will get the correct message.
There's this code:
$query = "SELECT to, from, rank, gender, picture, title, post FROM kaoscraft_posts WHERE to = 'username' ORDER BY msg_id DESC";
I have submitting it to the database down, and getting it, but I need to make sure the correct person gets the message.
Upvotes: 1
Views: 59
Reputation: 74217
to
and from
are reserved words which must be wrapped using backticks `
http://dev.mysql.com/doc/refman/5.5/en/reserved-words.html
$query = "SELECT `to`, `from`, rank, gender, picture, title, post FROM kaoscraft_posts WHERE `to` = 'username' ORDER BY msg_id DESC";
Yet, this
WHERE `to` = 'username'
may need to be
WHERE `to` = '$username'
which I suspect could be coming from a POST variable, which is not shown in your question.
If a part of your code resembles something to the effect of:
$username=$_POST['username'];
then use the following in its place:
WHERE `to` = '$username'
Upvotes: 1
Reputation: 139
When inserting to the database just provide the "From" or "To" field to your database. for example
$query = "SELECT * from MESSAGES where to = '$username'"
Upvotes: 0