NYCPHP Meetup

NYPHP.org

[nycphp-talk] Parse Error: Unexpected "; ", expected T_FUNCTION in Line 247

Phil Duffy phil at bearingasset.com
Fri Jul 1 12:33:21 EDT 2005


My thanks to Bill Kamm who solved this one.  The problematic code was as
follows:

 

if ($input->submit) {

    if (empty($input->info_item->item_no)) {

        $aErrors['item_no'] = 'Please fill in a item_no';

    }

    if (empty($input->info_item->author)) {

        $aErrors['author'] = 'Please fill in an author number';

    }

    if (empty($input->info_item->item_text)) {

        $aErrors['item_text'] = 'Please fill in an item_text';

}

 

 

Bill's diagnosis was,

 

"You are missing a closing bracket for the first if statement.  Add one and
you should be OK.  How did I find this?  I removed chunks of code a little
at a time, waiting for the error message to change.  I first got rid of all
the comments, then started removing entire functions.  When I got to
validate(), the error went away, so I looked closer at that code and found
it."  

 

The problem was actually that the third nested if condition wasn't
terminated by a "}", but the PHP translator would not have made that
distinction.  Bill's determination was actually correct in that sense.

 

It is interesting that the PHP translator thought the problem was an
unexpected ";", but that was probably because it picked up a subsequent ";"
before it picked up a "}".

 

Case closed.

 

Phil

  _____  

From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org] On
Behalf Of Phil Duffy
Sent: Friday, July 01, 2005 8:11 AM
To: 'NYPHP Talk'
Subject: RE: [nycphp-talk] Parse Error: Unexpected ";", expected T_FUNCTION
in Line 247

 

Bill,

 

The closing tag in this case is the same color as the opening tag, and is
the same color used in all "healthy" PHP scripts.  I still suspect that your
possibility is the best suspect, and perhaps my next step is to get a Zend
Developer editor.  I appreciate your offer to review the code, but it is 247
lines long and the List Moderator is currently blocking the posting of that
code on the list because of its length.

 

Phil

 

  _____  

From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org] On
Behalf Of Kamm, William R (Bill), ALABS
Sent: Wednesday, June 29, 2005 8:45 AM
To: NYPHP Talk
Subject: RE: [nycphp-talk] Parse Error: Unexpected ";", expected T_FUNCTION
in Line 247

 

Phil,

 

I use Dreamweaver as well for php.  For certain syntax errors that it
catches, it displays the closing php tag (?>) in a lighter color to tell you
something is missing or added.  Maybe a missing or extra parenthesis or
bracket, or a missing or extra semi colon.  If the file is not too large,
just paste it into an email, and I will take a look.

 

Bill

-----Original Message-----
From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org] On
Behalf Of Phil Duffy
Sent: Wednesday, June 29, 2005 9:02 AM
To: 'NYPHP Talk'
Subject: RE: [nycphp-talk] Parse Error: Unexpected ";", expected T_FUNCTION
in Line 247

Brian,

 

I did a Find Next on ";;" and found nothing, then a Find Next on ";" and
likewise found nothing suspicious.  I am using Macromedia's Dreamweaver
editor, which offers PHP editing with syntax coloring, but it did not
complain when I introduced the ";;" error.  I sense that this editor was not
designed for PHP but simply offers PHP editing as an add-on.  I'll
investigate Zend.  Thanks for the tip.

 

Phil

 


  _____  


From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org] On
Behalf Of Brian O'Connor
Sent: Wednesday, June 29, 2005 12:00 AM
To: NYPHP Talk
Subject: Re: [nycphp-talk] Parse Error: Unexpected ";", expected T_FUNCTION
in Line 247

 

The way I usually find it is through Zend, but I'm assuming you're not using
Zend, or another editor with the red underlining on errors.  My only
suggestion would be to do a search for a ';;' (two semi-colors), or try out
Zend :D

Good luck.

On 6/28/05, Phil Duffy <phil at bearingasset.com> wrote:

My thanks to the following who responded to my call for help:

 

Flavio - I tested your code and reproduced the same error message.

 

Brian - The extra ";" is the prime suspect, but two visual reviews have not
surfaced the problem.

 

Jeff - I suspect you are right about the missing (or extra) ";" further up
the code.  That makes sense.

 

Joseph - The suspects have been narrowed with the help of Flavio, Brian and
Jeff, but the problem is still unresolved.  What is the best way to send the
code - attachment or paste into e-mail?

 

Phil

 


  _____  


From: talk-bounces at lists.nyphp.org [mailto:
<mailto:talk-bounces at lists.nyphp.org>  talk-bounces at lists.nyphp.org] On
Behalf Of Joseph Crawford
Sent: Tuesday, June 28, 2005 2:11 PM
To: NYPHP Talk
Subject: Re: [nycphp-talk] Parse Error: Unexpected ";", expected T_FUNCTION
in Line 247

 

show your code ;)

-- 
Joseph Crawford Jr.
Codebowl Solutions, Inc.
1-802-671-2021
codebowl at gmail.com 


_______________________________________________
New York PHP Talk Mailing List
AMP Technology
Supporting Apache, MySQL and PHP
http://lists.nyphp.org/mailman/listinfo/talk
http://www.nyphp.org




-- 
Brian O'Connor 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20050701/f582e9c9/attachment.html>


More information about the talk mailing list