title: Google Map API v3 MySQL?
body: <p>I made a Google Map with API v3 with <a href="https://developers.google.com/maps/articles/phpsqlsearch_v3" rel="nofollow">this tutorial</a>.</p>
  
  <p>The .php is pulling results from the DB as you can see <a href="http://testforhealth.net/TCA/phpsqlsearch_genxml.php?lat=33&amp;lng=-86&amp;radius=50" rel="nofollow">here</a>.</p>
  
  <p>But when applied to with the google map searching comes back with no results as you can see <a href="http://testforhealth.net/TCA/collection.html" rel="nofollow">here</a>. </p>
  
  <p>The .html file isn't pulling the markers from the DB when searching for a location. Ive been over the code 100 times and looked for answers across the net on where I went wrong. 
  If someone could bring some light to this issue it would be greatly appreciated.</p>
  
  <p>Here is the .php</p>
  
  <pre><code>&lt;?php  
  require("phpsqlsearch_dbinfo.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);
  
  // 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());
  }
  
  // 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",
    mysql_real_escape_string($center_lat),
    mysql_real_escape_string($center_lng),
    mysql_real_escape_string($center_lat),
    mysql_real_escape_string($radius));
  $result = mysql_query($query);
  
  if (!$result) {
    die("Invalid query: " . mysql_error());
  }
  
  // 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>This is what the XML is putting out when I search Houston, TX in a 25 mile radius. </p>
  
  <pre><code> &lt;?xml version="1.0"?&gt;
  &lt;markers&gt;&lt;marker name="US Healthworks" address="9200 Hempstead, Houston, TX" lat="29.794104" lng="-95.449448" distance="5.34265857252369"/&gt;&lt;marker name="Concentra Urgent Care" address="1000 N Post Oak, Houston, TX" lat="29.785303" lng="-95.456039" distance="5.47896700195167"/&gt;&lt;marker name="US Healthworks" address="1414 S. Loop West, Houston, TX" lat="29.680426" lng="-95.399132" distance="5.79347704035615"/&gt;&lt;marker name="Concentra Urgent Care" address="8799 North Loop E., Houston, TX" lat="29.797531" lng="-95.273872" distance="6.28265385500935"/&gt;&lt;marker name="Doctor's Clinic Houston" address="6535 Southwest Freeway, Houston, TX" lat="29.717321" lng="-95.497299" distance="8.22610378379106"/&gt;&lt;marker name="Northshore Occupational Medica" address="1140 Westmont Ste. 505, Houston, TX" lat="29.771984" lng="-95.195290" distance="10.4743938030692"/&gt;&lt;marker name="US Healthworks" address="16630 Imperial, Houston, TX" lat="29.941263" lng="-95.396309" distance="12.615115596934"/&gt;&lt;marker name="NOVA" address="6630 Roxburgh Drive, Houston, TX" lat="29.866304" lng="-95.555901" distance="13.371308778454"/&gt;&lt;marker name="Fishbone Safety" address="208 X Street, Deer Park, TX" lat="29.694548" lng="-95.122627" distance="15.4859102039821"/&gt;&lt;marker name="US Healthworks" address="17410 N.W. Freeway, Houston, TX" lat="29.888929" lng="-95.582146" distance="15.5495324355371"/&gt;&lt;marker name="US Healthworks" address="10521 Corporate, Stafford, TX" lat="29.632973" lng="-95.596115" distance="16.2008784561048"/&gt;&lt;marker name="Occupational Healthcare" address="610 S. Main Street, Highlands, TX" lat="29.808447" lng="-95.056885" distance="19.0351671183224"/&gt;&lt;marker name="Medical Plaza Mobile Surveillance" address="10910 Spencer, La Porte, TX" lat="29.632973" lng="-95.062325" distance="20.4197847454651"/&gt;&lt;marker name="US Healthworks" address="1309 West Fairmont Pkwy, LaPorte, TX" lat="29.651571" lng="-95.030998" distance="21.6516577038734"/&gt;&lt;/markers&gt;
  </code></pre>