php script adding extra line in beginning of xml code

I have some code for a google api map I have created at
http://urbanbees.co.uk/maps/map_of_hive_locations_update.htm
which works fine in IE8 but not in chrome or firefox.

I was told that is becasuse the xml generated by
http://urbanbees.co.uk/maps/phpsqlajax_genxml3.php
is adding an extra blank first line before <?xml version="1.0" ?>

Does anyone know why this is and how I can fix it.

<?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(); ?>
which works fine in IE8 but not in chrome or firefox.

What works fine in IE8 and what doesn’t work in chrome or firefox ?
It’s hard to help if your question isn’t really clear… :frowning:

As I said the xml code has a blank line in line 1 which chrome and FF don’t recognise but IE does.
My question is why is the blank line appearing and can I change the code to stop it appearing.
I was told that the first line of xml code should not be blank.

Cheers

I have found the problem.

There was a space after the end of the php code in ‘phpsqlajax_dbinfo.php’ which was called from the above code.

Taking away the space after the ?> solved the issue.

Cheers

All solved

Ok !!
Glad to hear that your problem is fixed, although I’m sorry I wasn’t able to help immediatly…

Kind Regards,

Sponsor our Newsletter | Privacy Policy | Terms of Service