You don't need these lines...
>> <?xml version="1.0"?>
>> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
>> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
>>
>>
>> <html xmlns="http://www.w3.org/1999/xhtml">
>> <head>
>> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
>> <title>
>> Untitled Document
>> </title>
>> </head>
>> <body>
This next line must be right at the top, no white space or anything
before it (in fact, make sure there is no space before the < character
either)
>> <?php
>> require("mysql_connect.php");
>>
>> // Get parameters from URL
>> $center_lat = $_GET["lat"];
>> $center_lng = $_GET["lng"];
>> $radius = $_GET["radius"];
>>
>> // Start XML file, create parent node
This next line is what creates the <?xml preamble in the output, which
is why you don't need it explicitly
>> $dom = new DOMDocument("1.0");
>> $node = $dom->createElement("markers");
>> $parnode = $dom->appendChild($node);
>>
>> // Opens a connection to a mySQL server
>> $conn = mysql_connect($dbhost, $dbusername,$dbpass,$dbname);
>>
>> mysql_select_db($dbname);
>> if (! $conn)
>> die(mysql_error());
>>
>> // Set the active mySQL database
>> $db_selected = mysql_select_db($dbname, $conn);
>> 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);
>>
>> $result = mysql_query($query);
>> if (!$result) {
>> die("Invalid query: " . mysql_error());
>> }
>>
>> // 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();
>> ?>
Get rid of these next lines too.
>> </body>
>> </html>
> That is the file exactly:(
And it doesn't match the Google tutorial. I think you've edited it in
Dreamweaver (or HTMLTidy or something) and it's added all sorts of
HTML. You don't want that.
--
You received this message because you are subscribed to the Google Groups
"Google Maps API V2" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-maps-api?hl=en.