PC Nerd Posted June 27, 2006 Share Posted June 27, 2006 Hey guysim still having trouble with my if statements. im writing a script which checks form input. When i check the emails confirmation, php tells me that there is an unexpected "}". this is the closing curly brace for my if loopcan anyone help me......My code isif($_POST[Email] != $_POST[Email-confirm]){echo "Your Email was not correctly confirmed, please make sure that you enter the same Email in both fields.<br><br>";} Quote Link to comment https://forums.phpfreaks.com/topic/13002-php-if-statement/ Share on other sites More sharing options...
wildteen88 Posted June 27, 2006 Share Posted June 27, 2006 Can you post the code for the for loop. As the code you have provided is fine.Also make sure you place apostrophes ' around your indexes for your arrays like so:[code]if($_POST['Email'] != $_POST['Email-confirm'])[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13002-php-if-statement/#findComment-50003 Share on other sites More sharing options...
PC Nerd Posted June 27, 2006 Author Share Posted June 27, 2006 [!--quoteo(post=388416:date=Jun 27 2006, 07:13 PM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Jun 27 2006, 07:13 PM) [snapback]388416[/snapback][/div][div class=\'quotemain\'][!--quotec--]Can you post the code for the for loop. As the code you have provided is fine.Also make sure you place apostrophes ' around your indexes for your arrays like so:[code]if($_POST['Email'] != $_POST['Email-confirm'])[/code][/quote]thanks, ill give it a go Quote Link to comment https://forums.phpfreaks.com/topic/13002-php-if-statement/#findComment-50006 Share on other sites More sharing options...
wildteen88 Posted June 27, 2006 Share Posted June 27, 2006 No thats not the solution! I need you to post your for loop code here. Quote Link to comment https://forums.phpfreaks.com/topic/13002-php-if-statement/#findComment-50007 Share on other sites More sharing options...
PC Nerd Posted June 27, 2006 Author Share Posted June 27, 2006 i tried it and it didnt work. the error is:Parse error: syntax error, unexpected '}' in /WEB SITE/public_html/game/Email_Sender.php on line 30 Quote Link to comment https://forums.phpfreaks.com/topic/13002-php-if-statement/#findComment-50008 Share on other sites More sharing options...
wildteen88 Posted June 27, 2006 Share Posted June 27, 2006 I told you twice! POST the code for your forl oop! The bit I told you to change was just a suggestion, it wasnt a soloution. Quote Link to comment https://forums.phpfreaks.com/topic/13002-php-if-statement/#findComment-50014 Share on other sites More sharing options...
PC Nerd Posted June 27, 2006 Author Share Posted June 27, 2006 Fine, but it wont help. [code]<?php$newLine = "/n";echo "The infomation you entered is as follows. If it is incorrect, please re enter the information <a href = 'Emails.php'>here</a><br><br>";foreach($_POST as $field => $value){if(empty($_POST[$field])){echo "You left the <font color = 'red'>$field</font> field empty. If you want to submit the request please go back and fill in this field, <br><br>";echo "<a href = 'Emails.php'>click here to restart request</a>";echo "<br><br>";}else{continue;}}if($_POST['Email'] != $_POST['Email-confirm']){echo "Your Email was not correctly confirmed, please make sure that you enter the same Email in both fields.<br><br>";}else{break}echo "The information you gave was:<br><br>";echo "$_POST[First_Name], ";echo "$_POST[Last_Name]<br>";echo "$_POST[Age] yrs old<br><br>";echo "$_POST[Email]<br><br>";echo "$_POST[Reason]";}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/13002-php-if-statement/#findComment-50017 Share on other sites More sharing options...
wildteen88 Posted June 27, 2006 Share Posted June 27, 2006 Sorted your problems out.[code]$newLine = "/n";echo "The infomation you entered is as follows. If it is incorrect, please re enter the information <a href = 'Emails.php'>here</a><br><br>";foreach($_POST as $field => $value){ if(empty($_POST[$field])) { echo "You left the <font color = 'red'>$field</font> field empty. If you want to submit the request please go back and fill in this field, <br><br>"; echo "<a href = 'Emails.php'>click here to restart request</a>"; echo "<br><br>"; }}if($_POST['Email'] != $_POST['Email-confirm']){ echo "Your Email was not correctly confirmed, please make sure that you enter the same Email in both fields.<br><br>";}else{ echo "The information you gave was:<br><br>"; echo "$_POST[First_Name], "; echo "$_POST[Last_Name]<br>"; echo "$_POST[Age] yrs old<br><br>"; echo "$_POST[Email]<br><br>"; echo "$_POST[Reason]";}[/code]Your had an extra un-needed closing } braket in your code. Quote Link to comment https://forums.phpfreaks.com/topic/13002-php-if-statement/#findComment-50018 Share on other sites More sharing options...
PC Nerd Posted June 27, 2006 Author Share Posted June 27, 2006 sorted your problems out.thanks, that code was really being annoyingthanks, Quote Link to comment https://forums.phpfreaks.com/topic/13002-php-if-statement/#findComment-50019 Share on other sites More sharing options...
Guest edwinsweep Posted June 27, 2006 Share Posted June 27, 2006 hi pc nerd.i used to have the same mistake's as you have now.jedit made it alot easyer for meits a javascript based editor also suitable for PHP.jedit also keeps track of al the opening and closing tags in your script.and it changes color realtime so HTML is a different color than PHP, and mysql is yet another color.if you dont see the color's working in jedit its because you havent saved the file as a .PHP file yet.they say zend studio is also a good development platform.i havent tried it to be honest.good luck and cya later! Quote Link to comment https://forums.phpfreaks.com/topic/13002-php-if-statement/#findComment-50020 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.