I have a situation where I am running a PHP script in order to output the contents of a MYSQL database to XML. For some reason, the below code generates the desired result for the first 7 rows of the database and then it fails with the following error:
This page contains the following errors: error on line 1 at column 860: Encoding error
Below is a rendering of the page up to the first error."
(I am using the 'ID' column as a reference)
// Select all the rows in the markers table
$query = "SELECT * FROM markers WHERE 1";
$result = mysqli_query($database, $query);
if (!$result) {
die('Invalid query: ' . mysqli_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 = @mysqli_fetch_assoc($result)){
// Add to XML document node
echo '<marker ';
echo 'id="' . $ind . '" ';
echo 'name="' . parseToXML($row['name']) . '" ';
echo 'address="' . parseToXML($row['address']) . '" ';
echo 'lat="' . $row['lat'] . '" ';
echo 'lng="' . $row['lng'] . '" ';
echo 'type="' . $row['type'] . '" ';
echo '/>';
}
// End XML file
echo '</markers>';
The desired output here would be:
<markers>
<marker id="1" name="xxx" address="xxx" lat="xxx" lng="xxx" type="xxx"/>
<marker id="2" name="xxx" address="xxx" lat="xxx" lng="xxx" type="xxx"/>
...
</markers>
Having stared at this for hours I can't seem to figure it out, would love another set of eyes to have a look as I don't think there is anything necessarily wrong with the code, but was wondering whether there is some limitation in the method implemented?
Thanks in advance all, have a great day😊
$indmagically come from? Do you mean$row['id']@error silencer. If you got errors FIX 'EM