problem with geonames_query('countrycode', ...

HI,

I've some problems with geonames_query('countrycode', ..).
This function return always null.

Here our php code :

$query = array($form_values['latitude'], $form_values['longitude']);
$result = geonames_query('countrycode', $query);
if($result==NULL){
$pays='ko';
}

Could someone help us to fix this pb?
Thank You

Babel.

Serosero's answer worked for

Serosero's answer worked for me. I'm not very good with programming so I'd like to understand why we should use arrays.
_____________
Mathew Farney | Web Hosting

Hi Very Great stuff

Hi
Very Great stuff man
thanks for sharing.i have more useful to your tips.
keep on sharing

http://www.drupals-developers.com
http://www.drupal-web-developers.com

$lat =

$lat = $locat[latitude];
$long = $locat[longitude];

$query = array(
'lat' => $lat,
'lng' => $long
);

$result = geonames_query('countrycode', $query);
if($result){
print_r($result);
}
i tried this code but it still returns nothing but when i print $result, it shows me
stdClass Object ( [standalone] => no [total_results_count] => 0 [service] => countrycode [request] => Array ( [url] => http://ws.geonames.net/countrycode?username=&lat=31.5450500&lng=74.34068... [bytes] => 255 [cached] => data [seconds] => 0.00301885604858 ) [query] => Array ( [lat] => 31.5450500 [lng] => 74.3406830 [type] => xml ) )
where"[total_results_count] => 0" is zero.......
can anyone help me?

serosero's picture

The query parameter should

The query parameter should be an associative array, try the following:

$query = array(
'lat' => $form_values['latitude'],
'lng' => $form_values['longitude']
);

Syndicate content