mfleming Posted October 19, 2010 Share Posted October 19, 2010 I cannot see the error. I'm getting syntax errors on line 61 and line 67 indicated in comments on form. What am I missing? <?php $submit = $_POST['submit']; // Form Data $email = strip_tags($_POST['email']); $salonname = strip_tags($_POST['salonname']); if ($_POST[submit]) { echo "TRUE - CONTINUE_1"; //echo $_SESSION[key].' - '.$_POST[user_code].'<br>'; if ($_SESSION[key]==$_POST[user_code]) { echo "TRUE - CONTINUE_2"; $_SESSION[key]=''; } if ($salonname); { echo "TRUE - CONTINUE_3"; $email = trim($_POST['email']); if(!checkEmail($email)) { echo 'Invalid email address!'; echo "FALSE - STOP_4"; } else { echo "TRUE - CONTINUE_4"; // RUN Database Query } }//End IF salonname = TRUE else //LINE 61 {// STOP CODE echo "FALSE - STOP_3"; }// End salonanme check else //LINE 67 {// STOP CODE echo "FALSE - STOP_2"; }// End user code }// End if Sumbit else {// STOP CODE echo "FALSE - STOP_1"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/216217-cannot-find-syntax-error/ Share on other sites More sharing options...
BlueSkyIS Posted October 19, 2010 Share Posted October 19, 2010 what are the syntax errors? and those aren't lines 61 and 67 from where i'm counting. is there more code before or after this we're not seeing? Quote Link to comment https://forums.phpfreaks.com/topic/216217-cannot-find-syntax-error/#findComment-1123691 Share on other sites More sharing options...
mfleming Posted October 19, 2010 Author Share Posted October 19, 2010 Parse error: syntax error, unexpected T_ELSE in I have other valid <?php ?> above until line 24 Quote Link to comment https://forums.phpfreaks.com/topic/216217-cannot-find-syntax-error/#findComment-1123693 Share on other sites More sharing options...
kenrbnsn Posted October 19, 2010 Share Posted October 19, 2010 The semi-colon at the end of this statement <?php if ($salonname); ?> shouldn't be there. Ken Quote Link to comment https://forums.phpfreaks.com/topic/216217-cannot-find-syntax-error/#findComment-1123694 Share on other sites More sharing options...
BlueSkyIS Posted October 19, 2010 Share Posted October 19, 2010 yep. just going to post... Quote Link to comment https://forums.phpfreaks.com/topic/216217-cannot-find-syntax-error/#findComment-1123695 Share on other sites More sharing options...
mfleming Posted October 19, 2010 Author Share Posted October 19, 2010 Just fixed. Now I just have the error on LINE 67 Parse error: syntax error, unexpected T_ELSE in LINE 67 <?php $submit = $_POST['submit']; // Form Data $email = strip_tags($_POST['email']); $salonname = strip_tags($_POST['salonname']); if ($_POST[submit]) { echo "TRUE - CONTINUE_1"; //echo $_SESSION[key].' - '.$_POST[user_code].'<br>'; if ($_SESSION[key]==$_POST[user_code]) { echo "TRUE - CONTINUE_2"; $_SESSION[key]=''; } if ($salonname) { echo "TRUE - CONTINUE_3"; $email = trim($_POST['email']); if(!checkEmail($email)) { echo 'Invalid email address!'; echo "FALSE - STOP_4"; } else { echo "TRUE - CONTINUE_4"; // RUN Database Query } }//End IF salonname = TRUE else //LINE 61 {// STOP CODE echo "FALSE - STOP_3"; }// End salonanme check else //LINE 67 {// STOP CODE echo "FALSE - STOP_2"; }// End user code }// End if Sumbit else {// STOP CODE echo "FALSE - STOP_1"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/216217-cannot-find-syntax-error/#findComment-1123696 Share on other sites More sharing options...
BlueSkyIS Posted October 19, 2010 Share Posted October 19, 2010 you've got two else's in a row. i like my code a little differently arranged... <?php $submit = $_POST['submit']; // Form Data $email = strip_tags($_POST['email']); $salonname = strip_tags($_POST['salonname']); if ($_POST[submit]) { echo "TRUE - CONTINUE_1"; //echo $_SESSION[key].' - '.$_POST[user_code].'<br>'; if ($_SESSION[key]==$_POST[user_code]) { echo "TRUE - CONTINUE_2"; $_SESSION[key]=''; } if ($salonname) { echo "TRUE - CONTINUE_3"; $email = trim($_POST['email']); if (!checkEmail($email)) { echo 'Invalid email address!'; echo "FALSE - STOP_4"; } else { echo "TRUE - CONTINUE_4"; // RUN Database Query } } else { // STOP CODE echo "FALSE - STOP_3"; } else {// STOP CODE echo "FALSE - STOP_2"; }// End user code } else {// STOP CODE echo "FALSE - STOP_1"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/216217-cannot-find-syntax-error/#findComment-1123699 Share on other sites More sharing options...
mfleming Posted October 19, 2010 Author Share Posted October 19, 2010 Why cant I do that? Each else statement is within each IF statement? Doesn't this methodology work? //IF SUMBIT = TRUE THEN //IF USER_CODE = TRUE THEN //IF SALON NAME <> BAD CHARACTERS THEN //IF EMAIL = EMAIL IN DATEBASE THEN //CHANGE RANDOM CODE IN DATEBASE //SEND ID,SALONNAME,EMAIL,RANDOM_CODE TO EMAIL FROM DATEBASE //ELSE //EMAIL ADDRESS IS NOT IN DATABASE //STOP CODE //ELSE //SALON NAME IS INCORRECT, TRY AGAIN //STOP CODE //ELSE //PLESE RE-ENTER THE SECUIRTY CODE" CASE SENSITIVE //STOP CODE //ELSE //STOP END CODE Quote Link to comment https://forums.phpfreaks.com/topic/216217-cannot-find-syntax-error/#findComment-1123702 Share on other sites More sharing options...
BlueSkyIS Posted October 19, 2010 Share Posted October 19, 2010 i mean you've got one if statement with 2 else statements. which one should it pick? if ($salonname) { echo "TRUE - CONTINUE_3"; $email = trim($_POST['email']); if (!checkEmail($email)) { echo 'Invalid email address!'; echo "FALSE - STOP_4"; } else { echo "TRUE - CONTINUE_4"; // RUN Database Query } } else { // STOP CODE echo "FALSE - STOP_3"; } else {// STOP CODE echo "FALSE - STOP_2"; }// End user code Quote Link to comment https://forums.phpfreaks.com/topic/216217-cannot-find-syntax-error/#findComment-1123704 Share on other sites More sharing options...
mfleming Posted October 19, 2010 Author Share Posted October 19, 2010 Yea but doesn't the } after the else statement end that block? The next else if for the previous IF statement. Quote Link to comment https://forums.phpfreaks.com/topic/216217-cannot-find-syntax-error/#findComment-1123706 Share on other sites More sharing options...
BlueSkyIS Posted October 19, 2010 Share Posted October 19, 2010 yes, but you have to "re-open" the previous block with a right curly-bracket. if ($x == 1) { if ($y == 2) { // do this } else { // do that } } else { // some other code } Quote Link to comment https://forums.phpfreaks.com/topic/216217-cannot-find-syntax-error/#findComment-1123708 Share on other sites More sharing options...
BlueSkyIS Posted October 19, 2010 Share Posted October 19, 2010 actually, it's CLOSE the previous block. if(condition) { this } else { that } Quote Link to comment https://forums.phpfreaks.com/topic/216217-cannot-find-syntax-error/#findComment-1123710 Share on other sites More sharing options...
mfleming Posted October 19, 2010 Author Share Posted October 19, 2010 This seems to work. I'll continue from here. Thanks! <?php $submit = $_POST['submit']; // Form Data $email = strip_tags($_POST['email']); $salonname = strip_tags($_POST['salonname']); if ($_POST[submit]) { echo "TRUE - CONTINUE_1 "; //echo $_SESSION[key].' - '.$_POST[user_code].'<br>'; if ($_SESSION[key]==$_POST[user_code]) { echo "TRUE - CONTINUE_2 "; $_SESSION[key]=''; if ($salonname) { echo "TRUE - CONTINUE_3 "; $email = trim($_POST['email']); if(!checkEmail($email)) { die("Invalid email address!"); } else { // ENTER INFORMATION INTO DATEBASE } } else { // STOP CODE echo "FALSE - STOP_3"; }// End salonanme check } else { echo "FALSE - STOP_2"; }// End user code }// End if Sumbit else {// STOP CODE echo "FALSE - STOP_1"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/216217-cannot-find-syntax-error/#findComment-1123712 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.