Help - Parse error: syntax error, unexpected T_STRING on Line 35
Results 1 to 11 of 11

Thread: Help - Parse error: syntax error, unexpected T_STRING on Line 35

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    6

    Unhappy Help - Parse error: syntax error, unexpected T_STRING on Line 35

    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 Code:
    <?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;
    ?>

  2. #2
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,904
    If you look just above at the code you posted you can see where things go awry.
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  3. #3
    Junior Member
    Join Date
    Apr 2013
    Posts
    6
    Oh gosh. I see it now. It's hard to spot in a text editor but no excuse Thank you very much

  4. #4
    Senior Member Derokorian's Avatar
    Join Date
    Apr 2011
    Location
    Denver
    Posts
    1,787
    You should use an editor that provides syntax highlighting. There are plenty of free options available:
    Notepad++
    Komodo Edit (my personal choice)
    Sublime Text
    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

  5. #5
    Junior Member
    Join Date
    Apr 2013
    Posts
    6
    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?

  6. #6
    High Energy Magic Dept. NogDog's Avatar
    Join Date
    Aug 2006
    Location
    Ankh-Morpork
    Posts
    13,973
    PHP Code:
    header('Content-type: application/vnd.google-earth.kml+xml');
    header('Content-Transfer-Encoding: Binary'); 
    header('Content-disposition: attachment; filename="'.$file_name.'"'); 
    Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be." ~ from Nation, by Terry Pratchett

    "But the main reason that any programmer learning any new language thinks the new language is SO much better than the old one is because hes a better programmer now!" ~ http://www.oreillynet.com/ruby/blog/...ck_to_p_1.html


    eBookworm.us

  7. #7
    Junior Member
    Join Date
    Apr 2013
    Posts
    6
    That worked wonderfully! Thank you NogDog

  8. #8
    Member
    Join Date
    Nov 2009
    Location
    Mid-Hudson Valley, NYS
    Posts
    54
    Okay, for those of us to whom it was not obvious - where did things go awry in the original code?

  9. #9
    Pedantic Curmudgeon Weedpacket's Avatar
    Join Date
    Aug 2002
    Location
    General Systems Vehicle "Thrilled To Be Here"
    Posts
    21,904
    Quote Originally Posted by Francoise View Post
    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.
    THERE IS AS YET INSUFFICIENT DATA FOR A MEANINGFUL ANSWER
    FAQs! FAQs! FAQs! Most forums have them!
    Search - Debugging 101 - Collected Solutions - General Guidelines - Getting help at all

  10. #10
    Member
    Join Date
    Nov 2009
    Location
    Mid-Hudson Valley, NYS
    Posts
    54
    Thank you very much for your reply!

  11. #11
    Senior Member
    Join Date
    May 2013
    Location
    NYS
    Posts
    128
    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>;

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •