Hi Guys
Im new to php and i've been following a tutorial by Google Developers to generate a kml file. I keep getting the above error on line 35 (which I think is the header line). Please help. I've checked for the usual errors.
<?php
require('phpsql_dbinfo.php');
// Opens a connection to a MySQL server.
$connection = mysql_connect ($server, $username, $password);
if (!$connection)
{
die('Not connected : ' . mysql_error());
}
// Sets the active MySQL database.
$db_selected = mysql_select_db($database, $connection);
if (!$db_selected)
{
die ('Can\'t use db : ' . mysql_error());
}
// Selects all the rows in the markers table.
$query = 'SELECT * FROM locations WHERE 1';
$result = mysql_query($query);
if (!$result)
{
die('Invalid query: ' . mysql_error());
}
// Creates an array of strings to hold the lines of the KML file.
$kml = array('<?xml version="1.0" encoding="UTF-8"?>');
$kml[] = '<kml xmlns="http://earth.google.com/kml/2.1">';
$kml[] = ' <Style id="GreenLine">';
$kml[] = ' <LineStyle>';
$kml[] = ' <color>7f00ff00</color>';
$kml[] = ' <width>10</width>';
$kml[] = ' </LineStyle>';
$kml[] = ' </Style>
$kml[] = ' <Placemark id="Track">'; //Check inverted commas
$kml[] = ' <name>Shuttle Track</name>';
$kml[] = ' <description>This is the path that UKZN shuttleis currently following</description>';
$kml[] = '<styleUrl>#GreenLine</styleUrl>';
$kml[] = '<altitudeMode>absolute</altitudeMode>';
$kml[] = ' <LineString>';
$kml[] = ' <coordinates>';
// Iterates through the rows, printing a node for each row.
while ($row = @mysql_fetch_assoc($result))
{
$kml[] = $row['LONGITUDE'].','.$row['LATITUDE'].', 0';
}
// End XML file
$kml[] = ' </coordinates>';
$kml[] = ' </LineString>';
$kml[] = ' </Placemark>';
$kml[] = '</kml>';
$kmlOutput = join("\n", $kml);
header('Content-type: application/vnd.google-earth.kml+xml');
echo $kmlOutput;
?>