I was searching stackoverflow and got an answer to my question, but when I tried to implement it with my code I got weird errors.
here is the code:
SELECT `zip_code`, (6371 * acos(cos(radians($latitude)) * cos(radians(`lat`)) * cos(radians(`long`) - radians($longitude)) + sin(radians($latitude)) * sin(radians(`lat`)))) AS `distance`
FROM `places`
HAVING `distance` < $within
ORDER BY `distance` ASC
LIMIT 10;
I get the following error:
Incorrect parameter count in the call to native function 'radians'
I use MySQL version 5.1.44