title: Google Map API PHP Example
body: <p>I am using the creating store locator with PHP, MySQL and Google Maps example provided at <a href="https://developers.google.com/maps/articles/phpsqlsearch_v3" rel="nofollow">https://developers.google.com/maps/articles/phpsqlsearch_v3</a>. </p>
  
  <p>I am having issues getting the XML doc to write. I can run the query successful from Querious(DB app), but when attempting to run the provided script, which I modified to mysqli, things aren't working out for me. I am getting nothing returned. The DB is set up as supplied in the example. Here is the modified PHP that I use:</p>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>&lt;?php
  require_once('../includes/connection.php');
  require_once('../includes/function.php');
  
  // Get parameters from URL
  $center_lat = $_GET["lat"];
  $center_lng = $_GET["lng"];
  $radius = $_GET["radius"];
  
  // Start XML file, create parent node
  $dom = new DOMDocument("1.0");
  $node = $dom-&gt;createElement("markers");
  $parnode = $dom-&gt;appendChild($node);
  
  // Search the rows in the markers table
  $query = sprintf("SELECT address, name, lat, lng, ( 3959 * acos( cos( radians('%s') ) * cos( radians( lat ) ) * cos( radians( lng ) - radians('%s') ) + sin( radians('%s') ) * sin( radians( lat ) ) ) ) AS distance FROM markers HAVING distance &lt; '%s' ORDER BY distance LIMIT 0 , 20",
    mysqli_real_escape_string($mysqli , $center_lat),
    mysqli_real_escape_string($mysqli , $center_lng),
    mysqli_real_escape_string($mysqli , $center_lat),
    mysqli_real_escape_string($mysqli , $radius));
  $result = mysqli_query($mysqli, $query);
  $result = mysqli_query($mysqli, $query);
  if (!$result) {
    die("Invalid query: " . mysql_error());
  }
  
  header("Content-type: text/xml");
  
  // Iterate through the rows, adding XML nodes for each
  while ($row = @mysql_fetch_assoc($result)){
    $node = $dom-&gt;createElement("marker");
    $newnode = $parnode-&gt;appendChild($node);
    $newnode-&gt;setAttribute("name", $row['name']);
    $newnode-&gt;setAttribute("address", $row['address']);
    $newnode-&gt;setAttribute("lat", $row['lat']);
    $newnode-&gt;setAttribute("lng", $row['lng']);
    $newnode-&gt;setAttribute("distance", $row['distance']);
  }
  echo $dom-&gt;saveXML()
  ?&gt;
  </code></pre>
  
  <p>I know that both my connection are successful and that functions is error free. Thanks for any insight on this.</p>