[PHP] (SOLVED) Re: [PHP] parse error, unexpected T_ENCAPSED_AND_WHITESPACE
Ok, well the mystery is solved. Earlier in the script, I had used HEREDOC string delimiting to output some html blocks (I feel, asthetically, that HEREDOC is more readable than escaping out to HTML then back into PHP). Somehow, and I'm not sure how, because I don't remember typing the spaces, but somehow, exactly 4 spaces got inserted after each of my heredoc delimiter tokens in my script. Well, PHP isn't, apparently, smart enough to ignore the white space after the delimiter, and decided that the entire rest of my script constituted one large HEREDOC block. I only caught this after putting a copy of my script on my webserver with .phps extension and looking at it, and noticing that after the heredoc, all syntax highlighting stopped. So, I guess even though HEREDOC might be more pleasing to read (imho), it has a nasty class of syntax error that is *very* hard to detect (since it is very hard to 'see' that you have whitespace after the token). Caveat coder. Actually, I think I just figured out where the whitespace came from. My text editor has a feature, normally usefull, to do automatic indenting when you start a new line of code. I think it indented the cursor 4 spaces, and I hit 'home' and typed the delimiting token, and forgot about the whitespace at the end (normally, whitespace is ignored/collapsed by the parser). Jeff Schmidt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parse error, unexpected T_ENCAPSED_AND_WHITESPACE
Hello, I've made the source available at: http://www.weldingconsultants.com/wcapp/admin.phps Chris W. Parker wrote: print 'tdinput type=\'checkbox\' name=\'status[' . $row[profileID] . ']' . ' value='true'//td\n; Very likely the problem is not on line 82, but rather before it. Line 82 is just where the PHP parser finally gets screwed up. Yeah, that is what I was thinking too. But I can't find what the problem is earlier in the file. *sigh* $profID = $row[profileID]; print 'tdinput type=\'checkbox\' name=\'status[' . $profID . ']' . ' value='true'//td\n; When I had done that, the parser started choking at the top line. I suggest the following: (The HTML should all be on one line.) echo tdinput type=\checkbox\ name=\status[{$row['profileID']}]\ value=\true\ //td; I'll do that, simply because it is a little clearer to read, but I don't think the problem actually has to do with my string delimeters and escaping. For one thing, as I mentioned, the problem seems to be with $row[profileID], based upon the fact that I moved that out onto a line basically by itself, and the parser error 'moved' to that line. Please don't send attachments to a public mailing list. Besides, I don't think they go through anyway. Ok, I'll just post links in the future. I just thought it would be more convenient to attach it, but I can link, that's no problem. Also, from your followup: Ohh .. and if i read it more fully the first time I would have seen that you've got some funky in/out quoting problems and that you're not escaping the quotes wrapping 'true'. If you go back and look again, I don't need the single-quotes wrapping 'true' to be escaped, because that chunk of the string is wrapped in double-quotes. Yeah, I know, it's confusing lol. One of the problems of using PHP to print html, unfortunately. Well, part of the reason I have the string construction set up so strangely, is that I was testing out to see if certain things were causing problems. Originally I had it setup more like how you suggested. I only changed it to test some theories out about what might be causing the parser error. Jeff Schmidt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parse error, unexpected T_ENCAPSED_AND_WHITESPACE
Jeff Schmidt wrote: Hello, I've made the source available at: http://www.weldingconsultants.com/wcapp/admin.phps 404 error when I just tried. -- Teach a man to fish... NEW? | http://www.catb.org/~esr/faqs/smart-questions.html STFA | http://marc.theaimsgroup.com/?l=php-generalw=2 STFM | http://php.net/manual/en/index.php STFW | http://www.google.com/search?q=php LAZY | http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins signature.asc Description: OpenPGP digital signature
Re: [PHP] parse error, unexpected T_ENCAPSED_AND_WHITESPACE
Hello, Sorry about that. I took the source down after I solved the problem. The problem was a nasty type of syntax error caused by PHP implementation of HEREDOC string delimiting. I was using HEREDOC to stuff multiple lines of HTML into a string, in several places in my file, which is all fine and good. However, PHP does not recognize the delimiter token that marks the end of the string, if there is any whitespace on the same line. I had made sure that my token was all the way over to the beginning of the line, but what I *didn't* realize was that there was a couple spaces after the token. This caused the parser to basically treat the whole rest of the script file as a heredoc string, which is where the problems came from. Jeff Schmidt Jason Barnett wrote: Jeff Schmidt wrote: Hello, I've made the source available at: http://www.weldingconsultants.com/wcapp/admin.phps 404 error when I just tried. -- Teach a man to fish... NEW? | http://www.catb.org/~esr/faqs/smart-questions.html STFA | http://marc.theaimsgroup.com/?l=php-generalw=2 STFM | http://php.net/manual/en/index.php STFW | http://www.google.com/search?q=php LAZY | http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] parse error, unexpected T_ENCAPSED_AND_WHITESPACE
Jeff Schmidt mailto:[EMAIL PROTECTED] on Monday, March 14, 2005 2:58 PM said: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /hsphere/local/home/welding/weldingconsultants.com/wcapp/admin.php on line 82 Line 82 is: print 'tdinput type=\'checkbox\' name=\'status[' . $row[profileID] . ']' . ' value='true'//td\n; Very likely the problem is not on line 82, but rather before it. Line 82 is just where the PHP parser finally gets screwed up. $profID = $row[profileID]; print 'tdinput type=\'checkbox\' name=\'status[' . $profID . ']' . ' value='true'//td\n; When I had done that, the parser started choking at the top line. I suggest the following: (The HTML should all be on one line.) echo tdinput type=\checkbox\ name=\status[{$row['profileID']}]\ value=\true\ //td; I've attached the full file, to see the context that this is in. Please don't send attachments to a public mailing list. Besides, I don't think they go through anyway. Can *anyone* explain this error? It's completely breaking my script. I suspect, that the *real* error is somewhere earlier in the file, but I've read through it 20 times and just can't find anything out of place (can't find any obvious syntax errors, for example). Post the file to a web server somewhere in plain text. Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] parse error, unexpected T_ENCAPSED_AND_WHITESPACE
Chris W. Parker on Monday, March 14, 2005 3:15 PM said: Line 82 is: print 'tdinput type=\'checkbox\' name=\'status[' . $row[profileID] . ']' . ' value='true'//td\n; Very likely the problem is not on line 82, but rather before it. Line 82 is just where the PHP parser finally gets screwed up. Ohh .. and if i read it more fully the first time I would have seen that you've got some funky in/out quoting problems and that you're not escaping the quotes wrapping 'true'. :) Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parse error, unexpected T_ENCAPSED_AND_WHITESPACE
Chris W. Parker wrote: Chris W. Parker on Monday, March 14, 2005 3:15 PM said: Line 82 is: print 'tdinput type=\'checkbox\' name=\'status[' . $row[profileID] . ']' . ' value='true'//td\n; Very likely the problem is not on line 82, but rather before it. Line 82 is just where the PHP parser finally gets screwed up. Ohh .. and if i read it more fully the first time I would have seen that you've got some funky in/out quoting problems and that you're not escaping the quotes wrapping 'true'. :) Chris. that's because he's using single quotes for his value there, and double quotes to denote it being a string in that last part... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parse error, unexpected T_ENCAPSED_AND_WHITESPACE
Chris W. Parker wrote: Chris W. Parker on Monday, March 14, 2005 3:15 PM said: Line 82 is: print 'tdinput type=\'checkbox\' name=\'status[' . $row[profileID] . ']' . ' value='true'//td\n; Very likely the problem is not on line 82, but rather before it. Line 82 is just where the PHP parser finally gets screwed up. Ohh .. and if i read it more fully the first time I would have seen that you've got some funky in/out quoting problems and that you're not escaping the quotes wrapping 'true'. :) Quotes look ok to me? God bless VIM (even on this old windows box) :) In any case Chris' original suggestion is probably right... it's likely that the last place you used quotes *before* line 82 is missing a closing quote. -- Teach a man to fish... NEW? | http://www.catb.org/~esr/faqs/smart-questions.html STFA | http://marc.theaimsgroup.com/?l=php-generalw=2 STFM | http://php.net/manual/en/index.php STFW | http://www.google.com/search?q=php LAZY | http://mycroft.mozdev.org/download.html?name=PHPsubmitform=Find+search+plugins signature.asc Description: OpenPGP digital signature
Re: [PHP] parse error, unexpected T_ENCAPSED_AND_WHITESPACE
On Monday 14 March 2005 06:22 pm, Chris W. Parker wrote: Chris W. Parker on Monday, March 14, 2005 3:15 PM said: Line 82 is: print 'tdinput type=\'checkbox\' name=\'status[' . ^^ should be a slash?? $row[profileID] . ']' . ' value='true'//td\n; Very likely the problem is not on line 82, but rather before it. Line 82 is just where the PHP parser finally gets screwed up. Ohh .. and if i read it more fully the first time I would have seen that you've got some funky in/out quoting problems and that you're not escaping the quotes wrapping 'true'. :) Chris. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] parse error, unexpected T_ENCAPSED_AND_WHITESPACE
Jason Barnett mailto:[EMAIL PROTECTED] on Monday, March 14, 2005 3:57 PM said: Chris W. Parker wrote: Chris W. Parker on Monday, March 14, 2005 3:15 PM said: Line 82 is: print 'tdinput type=\'checkbox\' name=\'status[' . $row[profileID] . ']' . ' value='true'//td\n; Very likely the problem is not on line 82, but rather before it. Line 82 is just where the PHP parser finally gets screwed up. Ohh .. and if i read it more fully the first time I would have seen that you've got some funky in/out quoting problems and that you're not escaping the quotes wrapping 'true'. :) Quotes look ok to me? God bless VIM (even on this old windows box) :) I realized my mistake about two seconds after I'd send and decided not to reply to myself twice. :( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] parse error, unexpected T_ENCAPSED_AND_WHITESPACE
Why not make it simple?: // end PHP code ? tdinput type='checkbox' name='status[? echo $row['profileID']; ?]' value='true'/td ? // continue PHP code Dan T On Mar 14, 2005, at 3:58 PM, Jeff Schmidt wrote: Hello, I'm beating my head, and can't figure out *WHY* PHP is giving me this error. The full error text is: Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /hsphere/local/home/welding/weldingconsultants.com/wcapp/admin.php on line 82 Line 82 is: print 'tdinput type=\'checkbox\' name=\'status[' . $row[profileID] . ']' . ' value='true'//td\n; The problem seems to have something to do with the construct $row[profileID] - I say this, because I pulled that out into a seperate line before this, at one point, just to test, and assigned it to a variable, and put the variable in place of the array access. That is, to test, at one point, my file had: $profID = $row[profileID]; print 'tdinput type=\'checkbox\' name=\'status[' . $profID . ']' . ' value='true'//td\n; When I had done that, the parser started choking at the top line. I've attached the full file, to see the context that this is in. Can *anyone* explain this error? It's completely breaking my script. I suspect, that the *real* error is somewhere earlier in the file, but I've read through it 20 times and just can't find anything out of place (can't find any obvious syntax errors, for example). Thanks for any help you can give me, Jeff Schmidt -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php