SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 28

Hybrid View

  1. #1
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    unexpected T_STRING

    My eyes must not be working today, as I cannot see the error here:

    PHP Code:
    $brag '';

    echo <<< EOF
    <div id="rightcolumn"> 
    I'm getting the error on the <div> line. That's the exact code snippet, not retyped.
    Mike
    It's not who I am underneath, but what I do that defines me.

  2. #2
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    uh, don't you need
    PHP Code:
    echo '<<< EOF 
    <div id="rightcolumn">'

    ?
    - website

  3. #3
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    No, and there is more HTML after the <div> line anyhoo.

    And to those that will ask, yes, the ending token is there.
    Mike
    It's not who I am underneath, but what I do that defines me.

  4. #4
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, this is a bit small coding bit, doesn't say very much...
    ...only thing I can think is that the " is affecting the string, in that case doing \" would solve the case...

    hope that helps!
    - website

  5. #5
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    It shouldn't be that, as heredoc echos parse variables and quotes just fine.

    I don't really want to resort to normal echos using a bunch of \t 's for my formatting :|
    Mike
    It's not who I am underneath, but what I do that defines me.

  6. #6
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm, I see, not familiar with these advanced echo's :|

    Why not simply use
    PHP Code:
    ?><div id="rightcolumn"><?
    etc... ?

    but one thought though, shouldn't the EOF be right after the >>> ? no space ?
    >>>EOF
    Still this is wierd as I thought the php interprenter ignored whitespace... ...propably not in echo lines though...

    Just some thoughts though.
    - website

  7. #7
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Space doesn't matter :\
    Mike
    It's not who I am underneath, but what I do that defines me.

  8. #8
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Here's the full code, if it helps you at all.

    PHP Code:
    function pc_whb_right($pagename$subpage)
    {
    //    $news = include('./content/news.inc.php');
    //    $stats = include('./content/stats.inc.php');
        
    $brag '';

    echo <<<END
    <div id="rightcolumn">
            <table width="200" cellpadding="0" cellspacing="0" bgcolor="#FFE0B3" style="border: 1px solid #2142FF;">
                <tr>
                    <td>
                    <img src="img/rcolumn-news.gif" width="200" height="30" />
                    <div class="right-news">
    {$news}</div>
                    <img src="img/rcolumn-stats.gif" width="200" height="30" />
                    <div class="right-ststs">
    {$stats}</div>
                    <img src="img/rcolumn-brag.gif" width="200" height="30" />
                    <div class="right-brag">
    {$brag}</div>
                    </td>
                </tr>
            </table>
    </div>
    END;

    Mike
    It's not who I am underneath, but what I do that defines me.

  9. #9
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Am I to understand that that you don't need quotes before <<<END and after END;?

    Does it change anything if you place the starting <<<END on the line directly below the "echo"?
    John

  10. #10
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by PHP John
    Am I to understand that that you don't need quotes before <<<END and after END;?

    Does it change anything if you place the starting <<<END on the line directly below the "echo"?

    From my post above, I don't think it's the echo statement breaking, but no, you don't need quotes for a heredoc type echo statement. Yes, the <<< and token have to be on the same line, AFAIK.
    Mike
    It's not who I am underneath, but what I do that defines me.

  11. #11
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Oh, commenting out the entire echo statement still gives a parse error :|
    Mike
    It's not who I am underneath, but what I do that defines me.

  12. #12
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I just took your code changed it this way:
    PHP Code:
    <?php
    //    $news = include('./content/news.inc.php');
    //    $stats = include('./content/stats.inc.php');
        
    $brag '';
    echo <<<END
    <div id="rightcolumn">
            <table width="200" cellpadding="0" cellspacing="0" bgcolor="#FFE0B3" style="border: 1px solid #2142FF;">
                <tr>
                    <td>
                    <img src="img/rcolumn-news.gif" width="200" height="30" />
                    <div class="right-news">
    {$news}</div>
                    <img src="img/rcolumn-stats.gif" width="200" height="30" />
                    <div class="right-ststs">
    {$stats}</div>
                    <img src="img/rcolumn-brag.gif" width="200" height="30" />
                    <div class="right-brag">
    {$brag}</div>
                    </td>
                </tr>
            </table>
    </div>
    END;
    ?>
    Other than a few undefined variables it ran just fine.

    There have been times when I get this error, and can't find ANYTHING that causes it. In the end I retype it, and it works. It's like there is some control character that gets inserted somewhere.

    Maybe try copying your own code from here back in to your script and trying it again?
    John

  13. #13
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Heh, no dice

    I've retyped it twice, and tried your code. No matter what type of echo I do, or how many new lines/tabs/spaces I put somewhwere, it always errors on the <div> line.
    Mike
    It's not who I am underneath, but what I do that defines me.

  14. #14
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP John, check the echo in the manual, I just found this out too
    once again I must say that php allows too much...
    I don't know the solution to your problem but why not just swith out of php mode ?> ?
    - website

  15. #15
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That is very strange, because like I said, other than undefined variables it worked just fine on my machine...
    John

  16. #16
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Even this gives the error

    PHP Code:
    function pc_whb_right($pagename$subpage)
    {
        echo 
    'test';
    /**
    //    $news = include('./content/news.inc.php');
    //    $stats = include('./content/stats.inc.php');
        $brag = '';
    echo <<<END
    <div id="rightcolumn">
            <table width="200" cellpadding="0" cellspacing="0" bgcolor="#FFE0B3" style="border: 1px solid #2142FF;">
                <tr>
                    <td>
                    <img src="img/rcolumn-news.gif" width="200" height="30" />
                    <div class="right-news">{$news}</div>
                    <img src="img/rcolumn-stats.gif" width="200" height="30" />
                    <div class="right-ststs">{$stats}</div>
                    <img src="img/rcolumn-brag.gif" width="200" height="30" />
                    <div class="right-brag">{$brag}</div>
                    </td>
                </tr>
            </table>
    </div>
    END;
    **/

    Mike
    It's not who I am underneath, but what I do that defines me.

  17. #17
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Script is here by the way:
    http://www.webhostboast.com/test.php
    Mike
    It's not who I am underneath, but what I do that defines me.

  18. #18
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think there are some non-breaking spaces in there, as when I deleted the last one, and replaced the echo <<< with a breaking space it worked.

    did you copy it from a browser somewhere?
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.

  19. #19
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by cyborg from dh
    did you copy it from a browser somewhere?

    Nope, all typed up.
    Mike
    It's not who I am underneath, but what I do that defines me.

  20. #20
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This worked just fine, as well:
    PHP Code:
    <?php
    function pc_whb_right($pagename$subpage)
    {
    //    $news = include('./content/news.inc.php');
    //    $stats = include('./content/stats.inc.php');
        
    $brag '';
    echo <<<END
    <div id="rightcolumn">
            <table width="200" cellpadding="0" cellspacing="0" bgcolor="#FFE0B3" style="border: 1px solid #2142FF;">
                <tr>
                    <td>
                    <img src="img/rcolumn-news.gif" width="200" height="30" />
                    <div class="right-news">
    {$news}</div>
                    <img src="img/rcolumn-stats.gif" width="200" height="30" />
                    <div class="right-ststs">
    {$stats}</div>
                    <img src="img/rcolumn-brag.gif" width="200" height="30" />
                    <div class="right-brag">
    {$brag}</div>
                    </td>
                </tr>
            </table>
    </div>
    END;
    }
    pc_whb_right("foo""bar");
    ?>
    John

  21. #21
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by PHP John
    This worked just fine, as well:
    PHP Code:
    <?php
    function pc_whb_right($pagename$subpage)
    {
    //    $news = include('./content/news.inc.php');
    //    $stats = include('./content/stats.inc.php');
        
    $brag '';
    echo <<<END
    <div id="rightcolumn">
            <table width="200" cellpadding="0" cellspacing="0" bgcolor="#FFE0B3" style="border: 1px solid #2142FF;">
                <tr>
                    <td>
                    <img src="img/rcolumn-news.gif" width="200" height="30" />
                    <div class="right-news">
    {$news}</div>
                    <img src="img/rcolumn-stats.gif" width="200" height="30" />
                    <div class="right-ststs">
    {$stats}</div>
                    <img src="img/rcolumn-brag.gif" width="200" height="30" />
                    <div class="right-brag">
    {$brag}</div>
                    </td>
                </tr>
            </table>
    </div>
    END;
    }
    pc_whb_right("foo""bar");
    ?>

    Yeah, that worked fine for me :|
    Mike
    It's not who I am underneath, but what I do that defines me.

  22. #22
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Go figure...

    I'm guessing it is something above this function.
    Will you post the code above it?
    John

  23. #23
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Pardon me while I flip out like a ninja

    Thanks for your help guys.
    Mike
    It's not who I am underneath, but what I do that defines me.

  24. #24
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Care to let us in on what it was?
    John

  25. #25
    ********* Genius Mike's Avatar
    Join Date
    Apr 2001
    Location
    Canada
    Posts
    5,458
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    include("file.php');

    in the function above it.

    Mike
    It's not who I am underneath, but what I do that defines me.


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
  •