I've write this functions file:
<?php
function get_num_discos()
{
include ('connection.php');
$result = mysql_query("SELECT * FROM disco", $connect);
$num_rows = mysql_num_rows($result);
return $num_rows;
}
function get_disco_name_from_id($id)
{
include ('connection.php');
$query = 'SELECT name FROM disco WHERE id = '.$id;
$result = mysql_query($query,$connect);
while ($reg = mysql_fetch_array($result))
$name = $reg['name'];
return $name;
}
function get_lat_long_from_adress($adress)
{
$prepAddr = str_replace(' ','+',$address);
$geocode=file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$prepAddr.'&sensor=false');
$output= json_decode($geocode);
$lat = $output->results[0]->geometry->location->lat;
$long = $output->results[0]->geometry->location->lng;
return coords($lat,$long);
}
function get_closest_disco($client_adress)
{
include ('connection.php');
$num_discos = get_num_discos;
$client_adress = "C/ Sant Pau, 70, Lloret de Mar";
$client_coords($client_lat,$client_long) = get_lat_long_from_adress($client_adress);
$query = 'SELECT adress FROM disco';
$result = mysql_query($query,$connect);
while ($row = mysql_fetch_assoc($result))
{
$disco_adress[] = $row;
}
for ($i = 0; i<$num_discos; $i++)
{
$disco_coords($disco_lat,$disco_long) = get_lat_long_from_adress($disco_adress[$i]);
}
}
?>
But I'm getting the following error which I can't solve:
Fatal error: Can't use function return value in write context in C:\xampp\htdocs\discos_test\functions.php on line 47
The error points at: $client_coords($client_lat,$client_long) = get_lat_long_from_adress($client_adress);
(this is inside get_closest_disco function)
So is a problem related with the array it returns the function get_lat_long_from_adress($adress). I've just followed this link to make this function.
What's wrong? Any ideas? Thank you.