I am using an ajax script to send parameters and get a response to ajax.php
. This is working fine as I can send parameters and get a response. My problem is that when I echo the query in the ajax.php
script, I check on my browsers network. I see that the query is not complete and thus returns in an unexpected result. But when I execute the query within phpMyAdmin
then I get the correct result. Please help.
This is the actual query below
$lat = $_REQUEST['lat'];
$lon = $_REQUEST['lng'];
$db = new MysqliDb ('uveehae_road');
$results= $db->rawQuery('SELECT id, address, ( 6371 * acos( cos( radians('.$lat.') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('.$lon.') ) + sin( radians('.$lat.') ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance < 100 ORDER BY distance LIMIT 0,1');
This is what I see when I print the query and check on browser network
SELECT id, address, ( 6371 * acos( cos( radians(-26.0749518) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(28.1167666) ) + sin( radians(-26.0749518) ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance
As you can see the query is not complete but I don't know why.