title: PHP:Problems with Creating a Store Locator on Google Maps
body: <p>Can anyone tell me whats wrong with the code?I am new to php. I followed the instruction on <a href="https://developers.google.com/maps/solutions/store-locator/clothing-store-locator" rel="nofollow noreferrer">https://developers.google.com/maps/solutions/store-locator/clothing-store-locator</a> but cant get any result when appending ?</p>
  
  <pre><code>lat=-33&amp;lng=151.2&amp;radius=100
  </code></pre>
  
  <p>I also changed the code in storelocator.</p>
  
  <p>PHP CODE :</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=mysqli_connect('localhost','root','');
      if (!$connection) {
          die("Not connected : " . mysql_error());
      }
      // Set the active mySQL database
      $db_selected = mysqli_select_db($connection,'fyp');
      if (!$db_selected) {
          die ("Can\'t use db : " . mysql_error());
      }
  
      // Search the rows in the markers table
      $query = sprintf("SELECT id, name, address, 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($connection,$center_lat),
      mysqli_real_escape_string($connection,$center_lng),
      mysqli_real_escape_string($connection,$center_lat),
      mysqli_real_escape_string($connection,$radius));
      $result = mysqli_query($connection,$query);
      $result = mysqli_query($connection,$query);
      if (!$result) {
          die("Invalid query: " . mysql_error());
      }
  
      // Iterate through the rows, adding XML nodes for each
      while ($row = $result-&gt;fetch_assoc()){
          $node = $dom-&gt;createElement("marker");
          $newnode = $parnode-&gt;appendChild($node);
          $newnode-&gt;setAttribute("id", $row['id']);
          $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>