Re: Parse Error, Unexpected $

From: Date: Mon, 19 Jul 2004 11:14:31 +0000
Subject: Re: Parse Error, Unexpected $
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-190998@lists.php.net to get a copy of this message
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...!"; } ?>

« previous php.general (#190998) next »