I have a question that I have spent too many hours trying to resolve.I am using de Haversine formula to calculate the distance between two points, but the code that I'm using is giving me values that are too high for a distance like KM.Can someone help me?this is the code:\[code\]$pesquisa_raio = "%" . $_GET['raio'] . "%";$latitude = floatval("%" . $_GET['lat'] . "%");$longitude = floatval("%" . $_GET['log'] . "%");$cidade="%" . $_GET['cidade'] . "%";$sql= "SELECT * FROM oferta";//"add depois" //Inner Join concelhos On oferta.concelhos_id = concelhos.idconcelhos ";$query = mysql_query($sql);$array = mysql_fetch_array($query);$row = mysql_num_rows($query);//$sql_cidades = "SELECT * FROM oferta WHERE localizacao like '$pesquisa_loc'";if (isset($latitude) && isset($longitude)) { if ($row > 0) { do { $endereco=$array['concelho_id']; $request="http://maps.google.com/maps/api/geocode/json?address='.$endereco.'sensor=false"; $json_data=http://stackoverflow.com/questions/10559902/file_get_contents($request); $earth_radius = 6372.795477598; $lat_1 = floatval($latitude); $lon_1 = floatval($longitude); $lat_2 = 41.145570;//floatval($latitude2); $lon_2 = -8.627014;//floatval($longitude2); $delta_lat = $lat_2 - $lat_1 ; $delta_lon = $lon_2 - $lon_1 ; $alpha = $delta_lat/2; $beta = $delta_lon/2; $a = sin(deg2rad($alpha)) * sin(deg2rad($alpha)) + cos(deg2rad($lat_1)) * cos(deg2rad($lat_2)) * sin(deg2rad($beta)) * sin(deg2rad($beta)) ; $c = asin(min(1, sqrt($a))); $distance = 2*$earth_radius * $c; $distance = round($distance, 4); echo $distance."\n"; if($distance<=$pesquisa_raio){ $response = $array['titulo'] . "|"; } } while ($array = mysql_fetch_assoc($query)); json_encode($response);\[/code\]Is something wrong with the code, or is it that I can't understand the result?