title: Radius Search PHP, MYSQL and Google Maps
body: <p>Im searching a database with the latitude and longitude of a location. I want to retrieve all of the locations within a certain radius. </p>
  
  <p>I then encode the returned results into a JSON and retrieve the data using ajax, however I get an undefined error meaning that there is no data returned from the database.</p>
  
  <p>Can anybody see where im going wrong?</p>
  
  <p>Heres my query</p>
  
  <pre><code>$sql="SELECT *, ACOS( SIN( RADIANS( `lat` ) ) * SIN( RADIANS( $fLat ) ) + COS( RADIANS( `lat` ) )
  * COS( RADIANS( $fLat )) * COS( RADIANS( `lng` ) - RADIANS( $fLon )) ) * 6380 AS `distance`
  FROM `markers`
  WHERE ACOS( SIN( RADIANS( `lat` ) ) * SIN( RADIANS( $fLat ) ) + COS( RADIANS( `lat` ) )
      * COS( RADIANS( $fLat )) * COS( RADIANS( `lng` ) - RADIANS( $fLon )) ) * 6380 &lt; 10
      ORDER BY `distance`";
  
  
      $result = mysql_query($sql);
  
      while($r = mysql_fetch_assoc($result)) $rows[] = $r;
  
      echo json_encode($rows); 
  </code></pre>