SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Parse error: syntax error, unexpected T_SL

    Hi,

    I am trying to create an image gallery for my site. I am using the following code, but when I try to load the page I get the following error:


    Parse error: syntax error, unexpected T_SL in /home/users/uks53122/html/sportsmatesreunited.co.uk/photos/preupload.php on line 15

    This is line 15:
    $photo_category_list .= <<<__HTML_END

    Can anybody tell me why I am getting this message and how I fix the problem?

    Any help would be very much appriciated.


    PHP Code:
    <?php 
    include 'config.inc.php'

    // initialization 
    $photo_upload_fields ''
    $counter 1

    // If we want more fields, then use, preupload.php?number_of_fields=20 
    $number_of_fields = (isset($_GET['number_of_fields'])) ? 
    (int)(
    $_GET['number_of_fields']) : 5

    // Firstly Lets build the Category List 
    $result mysql_query('SELECT category_id,category_name FROM gallery_category'); 
    while(
    $row mysql_fetch_array($result)) { 
    $photo_category_list .= <<<__HTML_END 
    <option value="$row[0]">$row[1]</option>\
    __HTML_END


    mysql_free_result$result ); 

    // Lets build the Image Uploading fields 
    while($counter <= $number_of_fields) { 
    $photo_upload_fields .= <<<__HTML_END 
    <tr><td
    Photo {$counter}: 
    <
    input name="photo_filename[]" 
    type="file" /> 
    </
    td></tr
    <
    tr><td
    Caption
    <
    textarea name="photo_caption[]" cols="30" 
    rows="1"></textarea
    </
    td></tr
    __HTML_END
    $counter++; 


    // Final Output 
    echo <<<__HTML_END 
    <html
    <
    head
    <
    title>Lets upload Photos</title
    </
    head
    <
    body
    <
    form enctype="multipart/form-data" 
    action="upload.php" method="post" 
    name="upload_form"
    <
    table width="90%" border="0" 
    align="center" style="width: 90%;"
    <
    tr><td
    Select Category 
    <select name="category"
    $photo_category_list 
    </select
    </
    td></tr
    <!
    —Insert the image fields here --> 
    $photo_upload_fields 
    <tr><td
    <
    input type="submit" name="submit" 
    value="Add Photos" /> 
    </
    td></tr
    </
    table
    </
    form
    </
    body
    </
    html
    __HTML_END
    ?>
    Last edited by vigar_neil; Dec 12, 2006 at 11:47.

  2. #2
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    post ur code in php tags and make it some readable for us.
    thanks

  3. #3
    SitePoint Member
    Join Date
    Dec 2006
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi I've put it in PHP format.


    Could you have a quick look for me please and see if you have any suggestion?

    Many Thanks

  4. #4
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you cannot have any whitespace following the opening or closing identifier for a heredoc. retype that line. certain line endings might cause that as well.

    you can learn more about heredoc syntax here
    http://www.php.net/heredoc

  5. #5
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is very important to note that the line with the closing identifier contains no other characters, except possibly a semicolon (. That means especially that the identifier may not be indented, and there may not be any spaces or tabs after or before the semicolon. It's also important to realize that the first character before the closing identifier must be a newline as defined by your operating system. This is \r on Macintosh for example. Closing delimiter (possibly followed by a semicolon) must be followed by a newline too.

    If this rule is broken and the closing identifier is not "clean" then it's not considered to be a closing identifier and PHP will continue looking for one. If in this case a proper closing identifier is not found then a parse error will result with the line number being at the end of the script.

    It is not allowed to use heredoc syntax in initializing class members. Use other string syntaxes instead.

    Invalid example
    PHP Code:
    <?php
    class foo {
       public 
    $bar = <<<EOT
    bar
    EOT;}
    ?>

  6. #6
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by simplecode View Post
    It is not allowed to use heredoc syntax in initializing class members.
    Well, really... php will never stop amazing me. The principle of most surprise, that's it...

  7. #7
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  8. #8
    SitePoint Wizard stereofrog's Avatar
    Join Date
    Apr 2004
    Location
    germany
    Posts
    4,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for the link. I'm fully aware that this is documented. Unfortunately, even documented bug remains a bug.

  9. #9
    SitePoint Wizard simplecode's Avatar
    Join Date
    Jun 2006
    Posts
    1,129
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thats true


Bookmarks

Posting Permissions

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