I am trying to pass the city name taken from a set of reverse geocoded coordinates and then use that city name to query a database. However, when the variable containing the city name is passed in the mysqli query the reverse-geocoded city name (In this case, Vancouver) also includes unexpected square brackets. I cannot explain it.
See code:
echo $query = "SELECT * FROM `business` WHERE `city` = '".$city."' ";
In the console looks like:
SELECT * FROM business WHERE city = ' Vancouver' []
Entire function looks like this:
public function get_business_details($phase, $city) {
include_once "connect.php";
$returnJson = [];
echo $query = "SELECT * FROM `business` WHERE `city` = '".$city."' ";
$result = mysqli_query($con, $query);
while($row = mysqli_fetch_assoc($result)) {
$data = array( "business_name" => $row['business_name'], "address" => $row['address'], "description" => $row['description'], "identification" => $row['id']);
array_push($returnJson, $data);
}
if($phase=== "0") {
echo json_encode($returnJson);
}
if($phase === "1") {
return $returnJson;
}
}
Any help is greatly appreciated!