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 user_id!=20237 AND del_sender!=1 AND isreply!=1 AND DATE_FORMAT(dateposted, ' at line 1SELECT mesage_id,user_id,subject FROM mail_box WHERE sender_id= AND user_id!=20237 AND del_sender!=1 AND isreply!=1 AND DATE_FORMAT(dateposted, '%Y-%m-%d' ) = CURDATE() GROUP BY user_id