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 'AND u.id=c.user_id ORDER BY c.time ASC' at line 1 Query: "SELECT u.username, u.id, u.team, u.avatar, c.body, c.time FROM `blog_comments` as c, `users` as u WHERE c.blog_id= AND u.id=c.user_id ORDER BY c.time ASC;"