寻找距离的问题 - Haversine

时间:2017-08-30 05:02:28

标签: php

它始终将输出设为bool(false)。我有数据库的表列名LocationLongLocationLat

$ulat = $data['ULat'];
$ulong = $data['ULong'];

$sql = "SELECT PostId, (3959 * acos(cos(radians($ulat)) * cos(radians(LocationLat))
    * cos(radians(LocationLong) - radians($ulong)) + sin(radians($ulat))
    * sin(radians(lLocationLatat)))) AS distance
    FROM VehicleDetails HAVING distance < 250 ORDER BY distance LIMIT 0, 20";

$query = mysqli_query($con, $sql);
var_dump($query);

2 个答案:

答案 0 :(得分:0)

您没有考虑您的查询可能失败。从:

开始
$query = mysqli_query($con, $sql) or die('query fails');

var_dump($query);

答案 1 :(得分:0)

试试这个:

N/currentRecord

不要忽视错误检查!

您将获得发生的任何错误的描述,以便您可以在不猜测的情况下修复它。

HappyCoding