trying to use a query to get the distance from a certain location utilizing this query. we have the distances/locations set up in a db already. here's the query:
$query = "SELECT *, ( 6371 * acos( cos( radians($lat) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians($lng) ) + sin( radians($lat) ) * sin( radians( lat ) ) ) ) AS distance
FROM textloc HAVING distance < 20000 ORDER BY distance LIMIT 1;";
it keeps returning 'Incorrect parameter count in the call to native function 'radians' within the console. Obviously I'm doing something wrong here. any advice?
I know this is a late reply, but for all of you that are facing this issue:
This error means that the function is missing the parameter, in other words, it means that you are sending something like this to mysql
select radians();
This is not caused by a NULL nor caused by an empty value or by a missing column. In this situations radians() will return a different result:
select radians(NULL); #->returns NULL
select radians(''); #->returns 0
select radians(wrong_collumn); #->returns: Error Code: 1054. Unknown column 'wrong_collumn' in 'field list'
I hope this help out :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With