Unknowndady Posted June 11, 2012 Share Posted June 11, 2012 Hi, this is my first time posting. I am going through the "Creating a Store Locator with PHP, MySQL & Google Maps" and I am stuck, I have searched these forums and the web and have found cases such as mine but with no solution posted. When I try to test PHP file that initialize a new XML document and create the "markers" parent node I get only <markers/> My php file is the following <?php header("Content-type: text/xml"); ?> <?php require_once('../Connections/Conndb.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->createElement("markers"); $parnode = $dom->appendChild($node); // Opens a connection to a mySQL server $connection=mysql_connect ($hostname_Conndb, $username_Conndb, $password_Conndb); if (!$connection) { die("Not connected : " . mysql_error()); } // Set the active mySQL database $db_selected = mysql_select_db($database_Conndb, $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 < '%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()); } header("Content-type: text/xml"); // Iterate through the rows, adding XML nodes for each while ($row = @mysql_fetch_assoc($result)){ $node = $dom->createElement("marker"); $newnode = $parnode->appendChild($node); $newnode->setAttribute("name", $row['name']); $newnode->setAttribute("address", $row['address']); $newnode->setAttribute("lat", $row['lat']); $newnode->setAttribute("lng", $row['lng']); $newnode->setAttribute("distance", $row['distance']); } echo $dom->saveXML(); ?> Any help is appreciated; again I have found other post with similar problems but no posted solution. Thanks Mark Quote Link to comment https://forums.phpfreaks.com/topic/263971-google-store-locator-problem/ Share on other sites More sharing options...
Unknowndady Posted June 11, 2012 Author Share Posted June 11, 2012 I still have this problem but I kept going on with the tutorial and it all worked out. Thanks Mark Quote Link to comment https://forums.phpfreaks.com/topic/263971-google-store-locator-problem/#findComment-1352828 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.