What I am trying to do is I have entries in the database which have a lat/long stored with them. I want to calculate the distance between users lat/long and entries lat/long
Try this query. I found this one when googling but forgot who created it
SELECT a.*,
3956 * 2 * ASIN(SQRT( POWER(SIN(($lat - lat) * pi()/180 / 2), 2) + COS($lat * pi()/180) * COS(lat * pi()/180) *
POWER(SIN(($long - longi) * pi()/180 / 2), 2) )) as
distance FROM table
GROUP BY id HAVING distance <= 500 ORDER by distance ASC
$lat and $long variable is the current position of user. lat and longi is the latitude and longitudle of entries