Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have a typo in your request string: <code>adress</code> instead of <code>address</code>. The correct request string is:</p> <pre><code>$url = "http://maps.googleapis.com/maps/api/geocode/json?address=$adr&amp;sensor=false"; </code></pre> <p>And also you should better use PHP's <code>urlencode()</code> function for <code>$adr</code> parameter before pasting it into the request string. </p> <p>I've copy&amp;paste your code with changes listed before,i.e. I have:</p> <pre><code> $str = "Street 1 ZIP City"; $adr = urlencode($str); $url = "http://maps.googleapis.com/maps/api/geocode/json?address=$adr&amp;sensor=false"; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_ENCODING, ""); $curlData = curl_exec($curl); curl_close($curl); $address = json_decode($curlData); print_r($address); </code></pre> <p>Output in my browser for this example is:</p> <pre><code>stdClass Object ( [results] =&gt; Array ( [0] =&gt; stdClass Object ( [address_components] =&gt; Array ( [0] =&gt; stdClass Object ( [long_name] =&gt; 1st Street [short_name] =&gt; 1st St [types] =&gt; Array ( [0] =&gt; route ) ) [1] =&gt; stdClass Object ( [long_name] =&gt; Rock Hill [short_name] =&gt; Rock Hill [types] =&gt; Array ( [0] =&gt; locality [1] =&gt; political ) ) [2] =&gt; stdClass Object ( [long_name] =&gt; York [short_name] =&gt; York [types] =&gt; Array ( [0] =&gt; administrative_area_level_2 [1] =&gt; political ) ) [3] =&gt; stdClass Object ( [long_name] =&gt; South Carolina [short_name] =&gt; SC [types] =&gt; Array ( [0] =&gt; administrative_area_level_1 [1] =&gt; political ) ) [4] =&gt; stdClass Object ( [long_name] =&gt; United States [short_name] =&gt; US [types] =&gt; Array ( [0] =&gt; country [1] =&gt; political ) ) [5] =&gt; stdClass Object ( [long_name] =&gt; 29730 [short_name] =&gt; 29730 [types] =&gt; Array ( [0] =&gt; postal_code ) ) ) [formatted_address] =&gt; 1st Street, Rock Hill, SC 29730, USA [geometry] =&gt; stdClass Object ( [bounds] =&gt; stdClass Object ( [northeast] =&gt; stdClass Object ( [lat] =&gt; 34.9241861 [lng] =&gt; -81.01329 ) [southwest] =&gt; stdClass Object ( [lat] =&gt; 34.923073 [lng] =&gt; -81.0157245 ) ) [location] =&gt; stdClass Object ( [lat] =&gt; 34.923658 [lng] =&gt; -81.014494 ) [location_type] =&gt; GEOMETRIC_CENTER [viewport] =&gt; stdClass Object ( [northeast] =&gt; stdClass Object ( [lat] =&gt; 34.924978530291 [lng] =&gt; -81.013158269708 ) [southwest] =&gt; stdClass Object ( [lat] =&gt; 34.922280569709 [lng] =&gt; -81.015856230292 ) ) ) [partial_match] =&gt; 1 [types] =&gt; Array ( [0] =&gt; route ) ) [....more addresses here..] ) [status] =&gt; OK ) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload