Re: Parse Error, Unexpected $
| From: | Harlequin | Date: | Mon, 19 Jul 2004 12:19:29 +0000 |
| Subject: | Re: Parse Error, Unexpected $ | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-191003@lists.php.net to get a copy of this message | ||
Thanks Jason.
I've started doing that - damn well have to with nested IF statements.
--
-----------------------------
Michael Mason
Arras People
www.arraspeople.co.uk
-----------------------------
"Jason Barnett" <jasbarne@indiana.edu> wrote in message
news:20040719111435.72859.qmail@pb1.pair.com...
>
> >
> > But the error (line 40) is actually the last line...! :|
> >
>
> You had a missing brace. When the error line is the last line (and
especially
> if error is Undefined $end) then you likely have a missing ending brace or
> ending quote. Not trying to start a flame war here, but if you try a
different
> coding style you might have an easier time keeping track of open braces.
The
> working code (in my own style :)):
>
> <?php
>
> // Verify User Input:
> echo "<br><br><br>";
> $requiredFields = array('Title',
> 'ChristianName',
> 'Surname',
> 'HomePhone',
> 'Address01',
> 'City',
> 'Post code',
> 'Country',
> 'Gender',
> 'WorkPermitRequired',
> 'MyStatus');
> $errors = array();
> foreach($requiredFields as $fieldName) {
> // If using post, change $_GET to $_POST instead
> // You can use $_REQUEST if you're unsure of GET/POST
> if (empty($_REQUEST[$fieldName])) {
> $errors[] = 'Required field "' . $fieldName . '" empty!';
> }
> }
> if (count($errors)) {
> echo "Sorry ";
> echo $_SESSION['UserCName'];
> echo "<br><br>";
> echo "The Following Fields Require Input ~ Please Go Back.";
> echo "<br><br>";
> foreach($errors as $error) {
> echo $error . '<br><br>';
> }
> } else {
> echo "Hi...!";
> }
>
> ?>