title: Fetching JSON data using PHP from Google geocode API
body: <p>The first error I get is <code>"Call to undefined function get_file_contents() on line 18"</code>, I've tried to define get_file_contents() in the beginning of the file. The error dissappears, but nothing is displayed from <code>echo $lat;</code></p>
  
  <pre><code>&lt;?php 
      require_once('../db.php');
      $api_key = "somekey";
      $sqlQuery = mysql_query("SELECT `County` FROM `table`"); 
  
  
  
      /* Fetch county */ 
      while ($rows = mysql_fetch_array($sqlQuery))  { 
          $countyArr = $rows['County']; 
  
          /* Call google API and save coordinates for each county */ 
          $json = get_file_contents("https://maps.googleapis.com/maps/api/geocode/json?address=".$countyArr.",+CA&amp;key=".$api_key."");
          $obj = json_decode($json);
          if ($obj-&gt;status == "OK") {
              $lat = $obj-&gt;results-&gt;location-&gt;lat;
              $lng = $obj-&gt;results-&gt;location-&gt;lng;
  
              echo $lat;
          }
      }
  ?&gt;
  </code></pre>
  
  <p>This is the API I'm using:
  <a href="https://developers.google.com/maps/documentation/geocoding/get-api-key" rel="nofollow">https://developers.google.com/maps/documentation/geocoding/get-api-key</a></p>
  
  <p><em>Edit:</em>
  The error may be caused by php.ini settings on Godaddy's server for shared hosting. I tried to add <code>"allow_url_fopen = On"</code> in the php.ini I found in the root folder, although it still doesn't work.</p>