In my script I try to filter the selected data by its distance to the user. To achieve that I use this query which shall return every post in the radius of 10 kilometers:
$query = "SELECT * FROM Table WHERE ((rad2deg(acos((sin(deg2rad($actlat))*sin(deg2rad(lat))) + (cos(deg2rad($actlat))*cos(deg2rad(lat))*cos(deg2rad($actlon-lon))))))*111.13384) < 10";
The problem I‘m facing now is that I get this error returned:
Uncaught mysqli_sql_exception: FUNCTION database_name.rad2deg does not exist
So I tried it another way where the function works as it should:
$test = rad2deg(x);
echo $test;
Why can‘t I use the rad2deg
function in my query?