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

  • SEARCH
  • Home
  • 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 7949997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:08:04+00:00 2026-06-04T02:08:04+00:00

Hi im working through the Creating a store locator tutorial on google that can

  • 0

Hi im working through the Creating a store locator tutorial on google that can be found here.

https://developers.google.com/maps/articles/phpsqlsearch_v3#findnearsql

My code is

    // Select all 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("37.414832"),
  mysql_real_escape_string("-122.024857"),
  mysql_real_escape_string("37.414832"),
  mysql_real_escape_string("10"));


$result = mysql_query($sql);

if (!$result) 
{
  die('Invalid query: ' . mysql_error());
}
else
{
    echo 'success';
}

// Start XML file, echo parent node
echo "<markers>\n";
// Iterate through the rows, printing 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']);
}


// End XML file
echo "</markers>\n";
echo $dom->saveXML();

However when I run the script I get the error message

This page contains the following errors:
error on line 1 at column 1: Document is empty
Below is a rendering of the page up to the first error.

Can anybody see anything wrong with my code?

  • 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-04T02:08:05+00:00Added an answer on June 4, 2026 at 2:08 am

    The $dom object you are trying to create a element for doesn’t exist before the ‘while’ loop.
    Create that DOMDocument object first and include the <markers> rootnode in that object.

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

Sidebar

Related Questions

I'm new to Android and I'm working through a tutorial on programmatically creating a
In working through the issues with another question, I've found text files with embedded
I have been working on a Core Data iOS app that works perfectly through
I've been working on creating a subclass of db.Model that is automatically cached, i.e.:
Here is the sample site: http://tronitech.brettatkin.com/solutions.asp In IE 7, the drop-downs aren't working correctly
I'm working through the Agile Toolkit DVD rental example. In the Day3 - Creating
I'm working through some optimization work, and I've noticed that in some mysql dumps
I'm working on an iPhone app that unlocks further content through an in app
I've recently started creating a WPF application, and am just hoping that someone can
I'm working on a project in C that involves creating a user-level thread library

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.