Help - Parse error: syntax error, unexpected T_STRING on Line 35
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.
// Opens a connection to a MySQL server.
$connection = mysql_connect ($server, $username, $password);
die('Not connected : ' . mysql_error());
// Sets the active MySQL database.
$db_selected = mysql_select_db($database, $connection);
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);
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);
If you look just above at the code you posted you can see where things go awry.
Oh gosh. I see it now. It's hard to spot in a text editor but no excuse Thank you very much
You should use an editor that provides syntax highlighting. There are plenty of free options available:
Komodo Edit (my personal choice)
And many others
Sadly, nobody codes for anyone on this forum. People taste your dishes and tell you what is missing, but they don't cook for you. ~anoopmail
I'd rather be a comma, then a full stop.
User Authentication in PHP with MySQLi
- Don't forget to mark threads resolved - MySQL(i) warning
Thank you, I'll definitely go for one of those in future.
I have another question related to my code. The code is meant to generate a kml file and it does produce the right output but the file that downloads is a .php file which downloads straight to my downloads folder. Ideally, I want to save the .kml file to my www folder within wamp. Any ideas on how to fix that?
High Energy Magic Dept.
header('Content-disposition: attachment; filename="'.$file_name.'"');
That worked wonderfully! Thank you NogDog
Okay, for those of us to whom it was not obvious - where did things go awry in the original code?
In the line with the </Style> tag; a '; was missing.
Originally Posted by Francoise
Thank you very much for your reply!
A good thread for this newbie; sad to say, I didn't spot the missing semi-colon. IMO, things like that are easier to spot if an empty line precedes/follows each area of related code. As in, before <style> and after </style>;
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)