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 '' at line 5

SELECT cs.crimeid, l.locationid, l.lat, l.lng, l.location, ct.title AS crimetype, cy.crimemonth, cy.crimeyear FROM crime_s cs INNER JOIN location l ON (l.locationid = cs.locationid) INNER JOIN crimeyear cy ON (cy.ID = cs.crimeyearid) INNER JOIN crimetype ct ON (ct.typeid = cs.crimetypeid) WHERE MBRContains(GeomFromText('Polygon((51.932243283409 -0.28711412777617, 51.961156716591 -0.28711412777617, 51.961156716591 -0.24022187222383, 51.932243283409 -0.24022187222383, 51.932243283409 -0.28711412777617))'), l.pt) AND cs.crimeyearid=