Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Parse Error

  1. #1
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    284
    Thanks
    95
    Thanked 3 Times in 3 Posts

    Default Parse Error

    Esteemed PHP'ers:

    My PHP parser was quite happy with this statement:

    PHP Code:
    echo "<br /><br />Your final quota of hands for this session was " $numbers [$_SESSION["limit"]] . ".  This would have been hand number " $numbers [min (($_SESSION["bigCounter"] + 1), count ($numbers) - 1)] . ". BUT do not dispair:  You can begin a <i>new</i> session when our webmistress returns from " $excuses [(rand(0count($excuses) - 1))] . ".  She should be coming back in a while.  When she does, it will make her so happy if you are here.  We hope you will not disappoint her.  She will cheerfully review your starting quota of poker hands and, if necessary, adjust it.<br /><br />So hang out or, if necessary, come back later.  Or feel free to refresh your <i>quotation</i>, above.  You can do that while waiting!"
    In an effort to make this statement more elegant, I attempted interpolation:

    PHP Code:
    echo "<br /><br />Your final quota of hands for this session was $numbers [$_SESSION['limit']].  This would have been hand number $numbers [min (($_SESSION['bigCounter'] + 1), count ($numbers) - 1)]. For that reason, we must deny at the moment your efforts for a new hand.  We deny this new hand with respect and with love.  BUT do not dispair:  You can begin a <i>new</i> session when our webmistress returns from $excuses [(rand(0, count($excuses) - 1))].  She should be coming back in a while.  When she does, it will make her so happy if you are here.  We hope you will not disappoint her.  She will cheerfully review your starting quota of poker hands and, if necessary, adjust it.<br /><br />So hang out or, if necessary, come back later.  Or feel free to refresh your <i>quotation</i>, above.  You can do that while waiting!"
    My efforts resulted in this message:

    Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /home/marainla/public_html/pageContent/q-genp.txt on line 438

    On a hunch, I tried escaping some of the periods:

    PHP Code:
    echo "<br /><br />Your final quota of hands for this session was $numbers [$_SESSION['limit']]\.  This would have been hand number $numbers [min (($_SESSION['bigCounter'] + 1), count ($numbers) - 1)]\. For that reason, we must deny at the moment your efforts for a new hand.  We deny this new hand with respect and with love.  BUT do not dispair:  You can begin a <i>new</i> session when our webmistress returns from $excuses [(rand(0, count($excuses) - 1))]\.  She should be coming back in a while.  When she does, it will make her so happy if you are here.  We hope you will not disappoint her.  She will cheerfully review your starting quota of poker hands and, if necessary, adjust it.<br /><br />So hang out or, if necessary, come back later.  Or feel free to refresh your <i>quotation</i>, above.  You can do that while waiting!"
    That change generated the same error message.

    Next I tried eliminating some white space:


    PHP Code:
    echo "<br /><br />Your final quota of hands for this session was $numbers[$_SESSION['limit']].  This would have been hand number $numbers[min(($_SESSION['bigCounter']+1),count($numbers)-1)]. For that reason, we must deny at the moment your efforts for a new hand.  We deny this new hand with respect and with love.  BUT do not dispair:  You can begin a <i>new</i> session when our webmistress returns from $excuses[(rand(0, count($excuses)-1))].  She should be coming back in a while.  When she does, it will make her so happy if you are here.  We hope you will not disappoint her.  She will cheerfully review your starting quota of poker hands and, if necessary, adjust it.<br /><br />So hang out or, if necessary, come back later.  Or feel free to refresh your <i>quotation</i>, above.  You can do that while waiting!"
    and got...

    Parse error: syntax error, unexpected '[', expecting ']' in /home/marainla/public_html/pageContent/q-genp.txt on line 438

    Might someone please assist me in my quest for elegance?

    A.
    Last edited by marain; 01-07-2021 at 09:24 PM. Reason: Note Resolved

  2. #2
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,803
    Thanks
    1
    Thanked 253 Times in 248 Posts

    Default

    Hi there marain,

    I am not a PHP expert, but I believe that this amended code...

    PHP Code:
    echo "<br><br>
    Your final quota of hands for this session was "
     
    $numbers [$_SESSION['limit']] . 
    ". This would have been hand number "
     
    $numbers [min (($_SESSION['bigCounter'] + 1), count ($numbers) - 1)] . "
     . For that reason, we must deny at the moment your efforts
    for a new hand. We deny this new hand with respect and with love. BUT do not 
    despair: You can begin a <i>new</i> session when our web-mistress returns from" 
     
    $excuses [(rand(0count($excuses) - 1))] . ". She should be coming back in 
     a while. When she does, it will make her so happy if you are here. We hope you 
     will not disappoint her. She will cheerfully review your starting quota of poker 
     hands and, if necessary, adjust it.<br><br>
    So hang out or, if necessary, come back later. Or feel free to refresh your 
    <i>quotation</i>, above. You can do that while waiting!"

    ...will get you going again.

    coothead
    ~ the original bald headed old fart ~

  3. #3
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    284
    Thanks
    95
    Thanked 3 Times in 3 Posts

    Default

    Coothead,

    My initial inquiry was somewhat misleading. The page presently runs, using the original ineligant code. I'm just trying to use interpolation to make the code easier to read.

  4. #4
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,803
    Thanks
    1
    Thanked 253 Times in 248 Posts

    Default

    Hi there marain,

    is the code that I posted not easier to read?

    Perhaps we're not singing from the same hymn sheet.

    coothead
    ~ the original bald headed old fart ~

  5. #5
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    284
    Thanks
    95
    Thanked 3 Times in 3 Posts

    Default

    Coothead,

    It is indeed easier to read, and I thank you--I'm not one to look a gift horse in the mouth ;-) . My quest, however, is for interpolation that I believe will enable elimination of all internal quotation marks, leaving just the beginning and ending quotation marks. That, I believe, would be code easier still to read. My subsequent examples satisfy that quest. That's the good news. The bad news is that that new elegant code does not work.

  6. #6
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,803
    Thanks
    1
    Thanked 253 Times in 248 Posts

    Default

    Quote Originally Posted by marain View Post
    My quest, however, is for interpolation that I believe will enable
    elimination of all internal quotation marks, leaving just the
    beginning and ending quotation marks.

    I'm afraid, that's not possible.

    But, as I have pointed out, I am not a PHP expert.

    coothead
    ~ the original bald headed old fart ~

  7. #7
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    284
    Thanks
    95
    Thanked 3 Times in 3 Posts

    Default

    Coothead,

    You get an "A" for effort!

    Perhaps someone here who is an expert can educate both of us ;-)

    A.

  8. #8
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,803
    Thanks
    1
    Thanked 253 Times in 248 Posts

    Default

    Hi there marain,

    If a PHP guru is not forthcoming here then,
    take your query to this forum...

    https://forums.cutcodedown.com

    coothead
    Last edited by coothead; 01-07-2021 at 06:59 PM.
    ~ the original bald headed old fart ~

  9. #9
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    284
    Thanks
    95
    Thanked 3 Times in 3 Posts

    Default

    Many thanks, Coothead.

    I'll linger here for a while..we've given it now well less than half a day!

  10. #10
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    284
    Thanks
    95
    Thanked 3 Times in 3 Posts

    Default

    Modified the statement. Still it fails the syntax check, but I believe I'm making progress.

    The modification was to put the interpolated variables into braces ( { and } ). The statement now looks like this:

    PHP Code:
    echo "<br /><br />Your final quota of hands for this session was {$numbers[$_SESSION['limit']]}.  This would have been hand number {$numbers[min(($_SESSION['bigCounter']+1),count($numbers)-1)]}. For that reason, we must deny at the moment your efforts for a new hand.  We deny this new hand with respect and with love.  BUT do not dispair:  You can begin a <i>new</i> session when our webmistress returns from $excuses[(rand(0, count($excuses)-1))].  She should be coming back in a while.  When she does, it will make her so happy if you are here.  We hope you will not disappoint her.  She will cheerfully review your starting quota of poker hands and, if necessary, adjust it.<br /><br />So hang out or, if necessary, come back later.  Or feel free to refresh your <i>quotation</i>, above.  You can do that while waiting!"
    And this is the new error message:

    Parse error: syntax error, unexpected '(', expecting '-' or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in /home/marainla/public_html/pageContent/q-genp.txt on line 438

    Coothead?

    Anyone?

    A.

Similar Threads

  1. Resolved Parse error: syntax error unexpected 'echo'
    By Kage Kazumi in forum PHP
    Replies: 3
    Last Post: 10-21-2012, 08:19 PM
  2. Replies: 1
    Last Post: 01-28-2011, 03:39 AM
  3. Parse error: syntax error, unexpected $end
    By heavensgate15 in forum PHP
    Replies: 2
    Last Post: 02-24-2010, 06:38 AM
  4. Replies: 2
    Last Post: 02-12-2010, 09:53 AM
  5. Replies: 1
    Last Post: 04-26-2008, 11:22 AM

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
  •