Re: Parse Error, Unexpected $

From: Date: Mon, 19 Jul 2004 11:14:38 +0000
Subject: Re: Parse Error, Unexpected $
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-190999@lists.php.net to get a copy of this message
> else > { > echo "Hi...!"; > ?> You are missing a } at the end of the else. It should be: else { echo "Hi...!"; } ?> On Mon, 19 Jul 2004 12:02:47 +0100, Harlequin <michael.mason@arraspeople.co.uk> wrote: > Jim > > I deleted a whole load of lines and still get the error. I've narrowed it > down to this code: > > <?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 > if (empty($_POST[$fieldName])) > { > // The field is empty > $errors[] = 'Required field "' . $fieldName . '" empty!'; > } > } > if (count($errors)) > { > // Empty fields detected! > 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...!"; > ?> > > But the error (line 40) is actually the last line...! :| > > -- > ----------------------------- > Michael Mason > Arras People > www.arraspeople.co.uk > ----------------------------- > "Jim Root" <jimroot@gmail.com> wrote in message > news:b40826e104071903322a00024c@mail.gmail.com... > > > > I see one problem, but not the one you are talking about. > > > > > // Convert Values to Variables: > > > $Title = $_POST[Title]; > > > > This (and the rest of the post fields) should have quotes: > > > > $Title = $_POST["Title"]; > > > > (php looks for a constant named Title, instead of the string "Title") > > > > What line gives you the parse error? > > > > On Mon, 19 Jul 2004 11:10:09 +0100, Harlequin > > <michael.mason@arraspeople.co.uk> wrote: > > > I've checked my syntax but obviously missing something. > > > > > > Would anyone mind a quick scan: > > > > > > // Convert Values to Variables: > > > $Title = $_POST[Title]; > > > $ChristianName = $_POST[ChristianName]; > > > $MiddleName = $_POST[MiddleName]; > > > $Surname = $_POST[Surname]; > > > $HomePhone = $_POST[HomePhone]; > > > $Address01 = $_POST[Address01]; > > > $Address02 = $_POST[Address02]; > > > $Address03 = $_POST[Address03]; > > > $City = $_POST[City]; > > > $Postcode = $_POST[Postcode]; > > > $Country = $_POST[Country]; > > > $Nationality = $_POST[Nationality]; > > > $Gender = $_POST[Gender]; > > > $WorkPermitRequired = $_POST[WorkPermitRequired]; > > > $MyStatus = $_POST[MyStatus]; > > > > > > // Dump Data Into MembersData: > > > $UserDataDump = "INSERT INTO MembersData (Title, ChristianName, > > > MiddleName, Surname, DOB, TelephoneHome, Address01, Address02, > Address03, > > > AddressCity, AddressPostcode, AddressCountry, Nationality, Gender, > > > WorkPermit, Status) > > > > > > > > VALUES('$Title','$ChristianName','$MiddleName','$Surname','$HomePhone','$Add > > > > > ress01','$Address02','$Address03','$City','$Postcode','$Country','$Nationali > > > > > > ty','$Gender','$WorkPermitRequired','$MyStatus')"; > > > mysql_query($UserDataDump) or die("Couldn't Create User Data Entry. > MySQL > > > Error: " . mysql_error()); > > > > > > -- > > > ----------------------------- > > > Michael Mason > > > Arras People > > > www.arraspeople.co.uk > > > ----------------------------- > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > > > > > > > -- > > Jim Root > > jimroot@gmail.com > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Jim Root jimroot@gmail.com

« previous php.general (#190999) next »