I have no idea what I do wrong... this is my code:
SELECT * FROM messages WHERE userId = \"6\" OR toUserId = \"6\" OR toAll = \"1\" AND id <> \"4\" ORDER
I think your Query condition should be like this:
WHERE (userId = "6" OR toUserId = "6" OR toAll = "1") AND (id <> "4")
Your query will be evaluated to:
WHERE (userId = "6" OR toUserId = "6") OR (toAll = "1" AND id <> "4")
Which is not what you want.