[eluser]timtheelephant[/eluser]
I'm not sure on the actual issue's solution, but one thing I highly recommend you consider is using parameterized queries. It's not a big risk, but it is good practice.
Code:
$query = "SELECT users.username, bans.ban_reason
FROM bans
LEFT JOIN users ON users.user_id = bans.banned_by
WHERE bans.ban_time > NOW()
AND bans.banned_user =?";
$query = $this -> db -> query ( $query, Array($user_id) );
You also may want to consider a more efficient method for checking if someone's banned, such as a file that holds a list of names or some sort of broadcast that your client listens for, rather than querying every time the user does something (which is how I assume this implementation is supposed to work). Your database is a large bottleneck, and the less queries you have to run against it, the quicker your application will run.
Also, did you mean to do
Code:
LEFT JOIN users ON users.user_id = bans.banned_by
It seems like that would not be how you'd want to join those tables. Could be as simple as a wrong field name on your right table.