Google map with markers php mysql


I am hardly familiar with .php and don’t know anything about DOM or xml. I am following a google code to the “T”, and will make adjustments after I set it up with their sample data, and follow it over and over until I get a better understanding.
I am using the “Using PHP’s DOM functions to output xml” because I am using PHP5. But when I run the script, I don’t get a database error at all, evidenced by view source it shows the data, but I get:

XML Parsing Error: junk after document element
Location: http://myurl/mydirectory/phpsqlajax_genxml.php
Line Number 3, Column 1:

<?xml version="1.0"?>

It is commented on the page that it will be easier to debug database errors if I delete “header(“Content-type: text/xml”);”. But I don’t have database errors, and when I delete that I get a blank page (which proves that I don’t get a database error).

Everytime I look for this xml junk error, or search for this problem, I don’t find anyone with the same problem, I find ones that use ajax, other php’s, and js, but none following this code.

If anyone understands it, can they please tell me what’s wrong, why isn’t it recognizing “<” correctly.

Here is the sample code, in mine I of course changed localhost to point to my database server:

<?php require("phpsqlajax_dbinfo.php"); // 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 (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()); } // Select all the rows in the markers table $query = "SELECT * FROM markers WHERE 1"; $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)){ // ADD TO XML DOCUMENT NODE $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("type", $row['type']); } echo $dom->saveXML(); ?>