Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8858557
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:51:24+00:00 2026-06-14T14:51:24+00:00

I am using the creating store locator with PHP, MySQL and Google Maps example

  • 0

I am using the creating store locator with PHP, MySQL and Google Maps example provided at https://developers.google.com/maps/articles/phpsqlsearch_v3.

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:

PHP

<?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->createElement("markers");
$parnode = $dom->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 < '%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->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()
?>

I know that both my connection are successful and that functions is error free. Thanks for any insight on this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T14:51:26+00:00Added an answer on June 14, 2026 at 2:51 pm

    I wouldn’t be so sure about "error free" 🙂

    You are using the mysql_fetch_assoc() function (part of the deprecated mysql_* extensions) with mysqli, which are not compatible. The @ before this method call is hiding the error that you would normally see from the incorrect fetch of the data as an associative array.

    If you want to get an associative array with mysqli, you should use:

    $array = $result->fetch_assoc();
    

    http://php.net/manual/en/mysqli-result.fetch-assoc.php

    https://www.php.net/manual/en/language.operators.errorcontrol.php

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is a wonderful example of using Google maps for a store locator here:
I created a google maps store locator and im using a jquery pagination to
I'm creating a GWT app in Google App Engine, and using Google data store.
I am creating an application using CodeIgniter/MySQL. The problem is that when I store
Using MVC 2 I have been trying to make this record store project. Creating
After creating secret keys, how do I store them using the Keystore class' methods
I m creating document files using filemanager which is text file.i want to store
I am creating a database application using Visual C# Express and MySQL. The issue
I am creating multiple persistent store in my application, but I am using only
I am creating a store using Active Merchant and PayPal sandbox right now. It

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.