Query failed: 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 ') * sin(90 - attractionLatWGS84) * cos(- + attractionLonWGS84) + cos(90 - ) * c' at line 1 Actual query: SELECT attractionID, attractionName, localityName, attractionSummary, attractionLatWGS84, attractionLonWGS84, (3959 * acos(sin(90 - ) * sin(90 - attractionLatWGS84) * cos(- + attractionLonWGS84) + cos(90 - ) * cos(90 - attractionLatWGS84)) * pi()/180) as distance FROM attractions, localities WHERE attractionCompletion = 'black' AND attractionLocalityID = localityID AND (attractionLatWGS84 != AND attractionLonWGS84 != ) ORDER BY distance LIMIT 0, 20