Question : php syntax

Hi,
    when i call  the curl.php file in a browser, it displays the location information related to the supply coordinates
 
1:
2:
3:
4:
5:
6:
7:
8:
<?php
$curl_handle=curl_init();
//curl_setopt($curl_handle,CURLOPT_URL,'http://maps.google.com/maps/api/geocode/json?latlng=$lat,$lng&sensor=false');
curl_setopt($curl_handle,CURLOPT_URL,'http://maps.google.com/maps/api/geocode/json?latlng=53.290695,-6.273949&sensor=false');
curl_exec($curl_handle);
curl_close($curl_handle);

?>


i now want to supply the coordinates in a query string for example,
http://URL/curl.php?lat=53.123456&lng=-6.123456
however I'm having problems with the syntax in the  line below when i try to embed the variables in the query string...have played around with it but not getting the correct result
curl_setopt($curl_handle,CURLOPT_URL,'http://maps.google.com/maps/api/geocode/json?latlng=$lat,$lng&sensor=false');

any help appreciated
1:
2:
3:
4:
5:
6:
7:
8:
9:
<?php
$lat = $_GET['lat'];
$lng = $_GET['lng'];
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,'http://maps.google.com/maps/api/geocode/json?latlng=$lat,$lng&sensor=false');
curl_exec($curl_handle);
curl_close($curl_handle);

?>

Answer : php syntax

you have 2 ways, both below...
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
<?php
$lat = $_GET['lat'];
$lng = $_GET['lng'];
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,'http://maps.google.com/maps/api/geocode/json?latlng='.$lat.','.$lng.'&sensor=false');
curl_exec($curl_handle);
curl_close($curl_handle);

?>

<?php
$lat = $_GET['lat'];
$lng = $_GET['lng'];
$curl_handle=curl_init();
curl_setopt($curl_handle,CURLOPT_URL,"http://maps.google.com/maps/api/geocode/json?latlng=$lat,$lng&sensor=false");
curl_exec($curl_handle);
curl_close($curl_handle);

?>
Random Solutions  
 
programming4us programming4us