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 '%7Bid%7D' at line 2SQL: SELECT *, DATE_FORMAT(prem_date,'%d %M %Y') AS prem_date FROM shows WHERE shows.id = %7Bid%7D