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 g.published = 1' at line 1 SQL=SELECT count(*) FROM gtl_hwdvidsgroups AS g LEFT JOIN gtl_users AS u ON u.id = g.adminid WHERE AND g.published = 1