I'm getting an error that I believe to be very specific.
This PHP is stored in my domain. It access a server with a mysql database and uses it's table information to generate an XML with markers, that will afterwards be used in Google Map.
Actually it is working because it's retrieving the markers, but this error doesn't go away, and I don't know what's causing it. I'm very new to all the php and android programming. If someone could clarify this for me with easy explanation, I would be greatful.
The error is:
This page contains the following errors:
error on line 3 at column 1: Extra content at the end of the document
Below is a rendering of the page up to the first error.
And then it renders my expected result. I would like to solve and understand why this happens.
There you go my php code. I got from the tutorial (https://developers.google.com/maps/articles/phpsqlajax_v3):
<?php
require("db_config.php");
function parseToXML($htmlStr)
{
$xmlStr=str_replace('<','<',$htmlStr);
$xmlStr=str_replace('>','>',$xmlStr);
$xmlStr=str_replace('"','"',$xmlStr);
$xmlStr=str_replace("'",''',$xmlStr);
$xmlStr=str_replace("&",'&',$xmlStr);
return $xmlStr;
}
// Opens a connection to a MySQL server
$connection=mysql_connect ($mysql_host, $mysql_user, $mysql_password);
if (!$connection) { die('Not connected : ' . mysql_error());}
// Set the active MySQL database
$db_selected = mysql_select_db($mysql_database, $connection);
if (!$db_selected) {
die ('Can\'t use db : ' . mysql_error());
}
// Select all the rows in the markers table
$query = "SELECT * FROM Estac WHERE 1";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
header("Content-type: text/xml");
// Start XML file, echo parent node
echo '<markers>';
// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
echo '<marker>';
echo 'Name="' . parseToXML($row['Name']) . '" ';
echo 'Address="' . parseToXML($row['Address']) . '" ';
echo 'Tel="' . parseToXML($row['Tel']) . '" ';
echo 'Lat="' . $row['Lat'] . '" ';
echo 'Lng="' . $row['Lng'] . '" ';
echo 'Price="' . $row['Price'] . '" ';
echo '</marker>';
}
// End XML file
echo '</markers>';
?>
Thanks a lot!