I am having trouble with a PHP page and Google's Geocode service. I'm new at this, and may be overlooking something simple. I started with PHP code from Google's Geo Team written in 2007 and I believe my problem relates to adapting this Geocode V2 code the the current V3. Here are the three adaptations:

```
// Change the maps host, and keys are no longer used:
//define("MAPS_HOST", "maps.google.com"); V2 Geocode
//define("KEY", "abcdefg"); V2 Geocode
define("MAPS_HOST", "maps.googleapis.com"); // V3 Geocode

// Change the base URL:
//$base_url = "http://" . MAPS_HOST . "/maps/geo?output=xml" . "&key=" .  KEY V2 Geocode
$base_url = "http://" . MAPS_HOST . "/maps/api/geocode/xml?"; //V3 Geocode

// Change the request URL:
//  $request_url = $base_url . "&q=" . urlencode($address); V2 Geocode
$request_url = $base_url . "address=" . urlencode($address) . "&sensor=false";  V3 Geocode

```

I testing with four actual addresses in a MySQL database; these addresses come up normally in maps.google.com. Using the PHP below, all four addresses throw this error: 'This Address 1744 Crescent Ave, Idaho Falls, Idaho 83402 failed to geocoded again. Received status' (of course there are four different addresses and four errors.) There is no received status code. I've examined the $Address variable via echo and it seems to be normally formed.

Thanks in advance....

Here's the entire PHP page:

```
<?php

require("../../DatabaseCredentials.php");

define("MAPS_HOST", "maps.googleapis.com");

// Opens a connection to a MySQL server
$connection = mysql_connect(localhost, $username, $password);
if (!$connection) {
  die("Not connected : " . mysql_error());
}

// Set the active MySQL database
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected) {
  die("Can\'t use db : " . mysql_error());
}

// Select certain fields in the Houses table
$query = "
SELECT `Active`, `SaleTypeID`, `HouseID`, `Active`, `StreetNumber`, `StreetCardinal`, `StreetName`, `City`, `State`, `ZipCode`, `Latitude`, `Longitude` 
FROM `Houses` 
WHERE `HouseID` = 1519 OR `HouseID` = 1520 OR `HouseID` = 1525 OR `HouseID` = 1526
";
$result = mysql_query($query);
if (!$result) {
  die("Invalid query: " . mysql_error());
}

// Initialize delay in geocode speed
$delay = 0;
$base_url = "http://" . MAPS_HOST . "/maps/api/geocode/xml?";

// Iterate through the rows, geocoding each address
while ($row = @mysql_fetch_assoc($result)) {
  $geocode_pending = true;

  while ($geocode_pending) {
    $address = $row["StreetNumber"]." ".$row["StreetCardinal"]." ".$row["StreetName"].", ".$row["City"].", ".$row["State"]." ".$row["ZipCode"];  
    $id = $row["HouseID"];

    $request_url = $base_url . "address=" . urlencode($address) . "&sensor=false";  
    $xml = simplexml_load_file($request_url) or die("url not loading");

    $status = $xml->Response->Status->code;

    if (strcmp($status, "200") == 0) {
      // successful geocode
      $geocode_pending = false;
      $coordinates = $xml->Response->Placemark->Point->coordinates;

      $coordinatesSplit = split(",", $coordinates);
      $Latitude = $coordinatesSplit[0];
      $Longitude = $coordinatesSplit[1];
      $query = sprintf("UPDATE brents8_houses " .
             " SET Latitude = '%s', Longitude = '%s' " .
             " WHERE id = '%s' LIMIT 1;",
             mysql_real_escape_string($lat),
             mysql_real_escape_string($lng),
             mysql_real_escape_string($id));
      $update_result = mysql_query($query);
      if (!$update_result) {
        die("Invalid query: " . mysql_error());
      }
    } else if (strcmp($status, "620") == 0) {
      // sent geocodes too fast
      $delay += 100000;
    } else {
      // failure to geocode
      $geocode_pending = false;
      echo "This Address " . $address . " failed to geocoded again. ";
      echo "Received status " . $status . "
\n";
    }
    usleep($delay);
  }
}

?>

```