Parse error: syntax error, unexpected T_ENCAPSED_AND WHITESPACE, expecting T_STRING

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rhys
    New Member
    • Nov 2006
    • 25

    #31
    Originally posted by pbmods
    Heya, Rhys.

    Weird.

    I was thinking that maybe PHP thought that $price was a string, and earlier versions of PHP don't allow you to access an index of a string using array-style brackets.

    Except that wouldn't generate a parse error, and mysql_fetch_ass oc() never returns a string. And PHP 5 doesn't have the string index syntax problem anyway.

    Ah well.
    Yeah weird. I got it to successfully parse -- ALMOST -- by replacing the remaining brackets with parens. Now I'm getting a parse error -- "unexpected $end in..." the line past my end. My last line is </html> on line 343, and this error occurs on line 344. It has me poring over my code again, looking for a {} or [] or "" mismatch, as yet unsuccessfully, and i'm wondering if i have other structure issues, with my html or something. Researching that now. I guess i can confuse a parser, huh. My application, though voluminous and will get way more so, is not all that complex or hard to decipher. Maybe I should go back and replace previous []'s which worked (apparently) with () and see if they still parse. Like my ex-guru, 3 gurus ago, said: If it was easy, everybody would do it. Thanks for your interest!! -- Rhys

    Comment

    • pbmods
      Recognized Expert Expert
      • Apr 2007
      • 5821

      #32
      Heya, Rhys.

      Couple of thoughts.
      • Do you have any 'gremlins' in your code (non-printable characters)? You oftentimes will get these when copying code from a website. I know that BBEdit is really good at zapping gremlins, but that's the extent of my experience.
      • Do you have any kind of a quote mismatch somewhere in your code? Perhaps you opened a quote with a ' but closed it with a " or vice versa? Does your editor use syntax highlighting?
      • Did you close a PHP block but forget to open it again or vice versa? For example:
        [code=php]
        <?php
        if( {condition} )
        {
        ?>
        <div>
        Output some HTML because {condition} is true!
        </div>

        // Oops.... forgot something!
        }
        [/code]
      • Did you open a comment block but forget to close it? E.g.,:
        [code=php]
        if( {condition} )
        {
        /*
        I changed my mind; I don't want this code to execute.
        $_res = mysql_query( ... );
        $_row = mysql_fetch_ass oc($_res);
        mysql_free_resu lt($_res);
        }
        /*
        I'd rather do this instead....
        */
        mysql_query( ... );
        [/code]


      If it sounds like I'm grasping at straws, well....

      You may want to ZIP your source files and attach them ('attach' is available when you are editing a post) so that we can look at the entire script.

      Comment

      • rhys
        New Member
        • Nov 2006
        • 25

        #33
        contains sourve

        Originally posted by pbmods
        Heya, Rhys.

        Couple of thoughts.
        • Do you have any 'gremlins' in your code (non-printable characters)? You oftentimes will get these when copying code from a website. I know that BBEdit is really good at zapping gremlins, but that's the extent of my experience.
        • Do you have any kind of a quote mismatch somewhere in your code? Perhaps you opened a quote with a ' but closed it with a " or vice versa? Does your editor use syntax highlighting?
        • Did you close a PHP block but forget to open it again or vice versa? For example:
          [code=php]
          <?php
          if( {condition} )
          {
          ?>
          <div>
          Output some HTML because {condition} is true!
          </div>

          // Oops.... forgot something!
          }
          [/code]
        • Did you open a comment block but forget to close it? E.g.,:
          [code=php]
          if( {condition} )
          {
          /*
          I changed my mind; I don't want this code to execute.
          $_res = mysql_query( ... );
          $_row = mysql_fetch_ass oc($_res);
          mysql_free_resu lt($_res);
          }
          /*
          I'd rather do this instead....
          */
          mysql_query( ... );
          [/code]


        If it sounds like I'm grasping at straws, well....

        You may want to ZIP your source files and attach them ('attach' is available when you are editing a post) so that we can look at the entire script.
        I reviewed my code more closely, and found a couple of minor issues, but nothing which affected this error. I moved my html around, though it is scarcely necessary for this program, also with no effect.

        I zipped up that file, and I must be the dumbest guy in town, because I can't see where to attach it to this. All tips welcome. Thx again!! --

        Found it!!
        Rhys
        Attached Files
        Last edited by rhys; Aug 28 '07, 01:04 AM. Reason: found it

        Comment

        • pbmods
          Recognized Expert Expert
          • Apr 2007
          • 5821

          #34
          Heya, Rhys.

          On line 65, you have a misplaced backtick.

          Comment

          • rhys
            New Member
            • Nov 2006
            • 25

            #35
            Originally posted by pbmods
            Heya, Rhys.

            On line 65, you have a misplaced backtick.
            Well, skin me alive!! I DIDN'T EVEN SEE IT!! Even when you pointed it out -- my editor showed 65 to be the line above -- I STILL had a hard time finding it. I won't blame the tiny screen on my development laptop, or its 640x480 resolution, or my bifocals, which are obviously not progressive enough. Or the propensity for the human brain -- or at least mine -- to subconsciously ignore what it does not fathom. But your idea of a syntax-highlighting editor has much merit at this point. I've been using vi forever. Can you suggest a similar editor, preferably open-source, which highlights code?

            I have no idea how or when that got in there, let alone why. Maybe the cat did it. And the parser!! You would've thought, after a while, it'd know I didn't mean that!! I mean c'mon, enough is enough, right? Ha!! Computers aren't smart -- they're just fast.

            All kidding aside, I'm sure the parser probably took everything it saw, after that `, as a string, in lieu of an opposing `, and complained about string violations. I went through last night, after fixing that, and unfixed a lot of stuff, no longer necessary, and changed the rest back to proper [] format. And it WORKS!! I'm happy to report that I am now successfully updating those pesky subtotals records -- I mean, rows.

            I'm sorry I wasted your time with my ignorance and blindness, hope that does not happen again. But thank you again and again for your patience and indulgence; this one was driving me crazy, and I was about to cry or something. And again, any editor suggestions are welcome.

            Thank you again, and go in Peace!! -- Rhys

            Comment

            • pbmods
              Recognized Expert Expert
              • Apr 2007
              • 5821

              #36
              Heya, Rhys.

              For Mac OS X, Bare Bones Software makes a very nice free app called TextWrangler. For about $80 you can upgrade to their fully-featured (and very much awesome) BBEdit. But TextWrangler by itself is still a fantastic (did I mention free?) app.

              [EDIT: Of course, BBEdit does not currently recognize the backtick operator as a string delimiter, so even that would not have helped in this case.]

              [EDIT EDIT: You can also set up syntax highlighting in vim. Check out this article.]

              And in terms of missing the backtick, I did too, for about half an hour. I finally decided to go in and refactor your code to see if there was whitespace where there shouldn't be any. The first step when I refactor is to remove all indenting, and one line just refused to indent all the way....

              The backtick is, incidentally, an operator in PHP. It is equivalent to calling shell_exec() on an equivalent string.

              Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)

              Comment

              • rhys
                New Member
                • Nov 2006
                • 25

                #37
                Originally posted by pbmods
                Heya, Rhys.

                For Mac OS X, Bare Bones Software makes a very nice free app called TextWrangler. For about $80 you can upgrade to their fully-featured (and very much awesome) BBEdit. But TextWrangler by itself is still a fantastic (did I mention free?) app.

                [EDIT: Of course, BBEdit does not currently recognize the backtick operator as a string delimiter, so even that would not have helped in this case.]

                [EDIT EDIT: You can also set up syntax highlighting in vim. Check out this article.]

                And in terms of missing the backtick, I did too, for about half an hour. I finally decided to go in and refactor your code to see if there was whitespace where there shouldn't be any. The first step when I refactor is to remove all indenting, and one line just refused to indent all the way....

                The backtick is, incidentally, an operator in PHP. It is equivalent to calling shell_exec() on an equivalent string.

                Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
                Thank you again!! My local Linux guru begged off on this one, nasty summer cold, but I think my code scared him. That, or he just didn't want to wade through it. Too bad -- he uses a souped-up version of the jed editor, may well have spotted it.

                I can't tell you how many times, over the last several years and 2 previous incarnations of this system, I have felt totally alone in this world, on a sea of one, storm raging, no land in sight, no phones to ring.

                Your immediate response, and ongoing concern, were a lifesaver this time, Buddy, and I was floundering!! It is this level of concern which insures that Open Source will prevail -- try getting support that fast from Microsoft!!

                Long live Open Source, and God Bless you!! -- Rhys

                Comment

                Working...