I am trying to build an Android app which queries a server to get the latitude and longitude for the given destination. However there seems to be an error in my PHP code as it shows the following error when I input the address in the web browser.
Notice: Undefined variable: destination in C:\xampp\htdocs\serverfiles\btc.php on line 6
{"result":[{"latitude":null,"longitude":null}]}
This is my btc.php file:
<?php
if($_SERVER['REQUEST_METHOD']=='GET'){
$id = $_GET['destination'];
$con = mysqli_connect("127.0.0.1", "root", "", "bustrack");
$sql = "SELECT * FROM updates WHERE destination='".$destination."'";
$r = mysqli_query($con,$sql);
$res = mysqli_fetch_array($r);
$result = array();
array_push($result,array(
"latitude"=>$res['latitude'],
"longitude"=>$res['longitude'],
)
);
echo json_encode(array("result"=>$result));
}