NLT Posted April 22, 2012 Share Posted April 22, 2012 if(mysql_num_rows($query) == 1) { $compny = mysql_query("SELECT * FROM company WHERE value='". $comp ."'"); $company = mysql_result($compny, 0); if(mysql_num_rows($company) == 0) { echo "Company not found"; die(); } $getcompstt = mysql_query("SELECT stat FROM company WHERE value='". $comp ."' LIMIT 1"); $getcompstat = mysql_result($getcompstt, 0); elseif($getcompstat == "3") Quote Link to comment https://forums.phpfreaks.com/topic/261440-syntax-error-unexpected-t_elseif/ Share on other sites More sharing options...
kicken Posted April 22, 2012 Share Posted April 22, 2012 You should write something describing your problem rather than just post code. if(mysql_num_rows($query) == 1) { $compny = mysql_query("SELECT * FROM company WHERE value='". $comp ."'"); $company = mysql_result($compny, 0); if(mysql_num_rows($company) == 0) { echo "Company not found"; die(); } $getcompstt = mysql_query("SELECT stat FROM company WHERE value='". $comp ."' LIMIT 1"); $getcompstat = mysql_result($getcompstt, 0); elseif($getcompstat == "3") You have an elseif there at the end that is not attached to any preceding if statement. Quote Link to comment https://forums.phpfreaks.com/topic/261440-syntax-error-unexpected-t_elseif/#findComment-1339666 Share on other sites More sharing options...
NLT Posted April 22, 2012 Author Share Posted April 22, 2012 if(mysql_num_rows($query) == 1) { $compny = mysql_query("SELECT * FROM company WHERE value='". $comp ."'"); $company = mysql_result($compny, 0); if(mysql_num_rows($company) == 0) { echo "Company not found"; die(); } $getcompstt = mysql_query("SELECT stat FROM company WHERE value='". $comp ."' LIMIT 1"); $getcompstat = mysql_result($getcompstt, 0); elseif($getcompstat == "3") { echo "Cannot find company"; die(); } Sorry for not explaining - I wasn't sure how to. That is the elseif statement, from the elseif I am having trouble, as you know it is giving me errors. Quote Link to comment https://forums.phpfreaks.com/topic/261440-syntax-error-unexpected-t_elseif/#findComment-1339669 Share on other sites More sharing options...
jcanker Posted April 22, 2012 Share Posted April 22, 2012 You are running other statements after the preceding if but before you use elseif. elseif must come immediately after the close of the preceding if: if(condition1) { echo "foo"; }//end of if elseif(condition2) { echo "bar"; } You have something like: if(condition1) { echo "foo"; }//end of if echo "I have some stuff here after if but before elseif--I can't use elseif after this! elseif(condition2) { echo "bar"; } Quote Link to comment https://forums.phpfreaks.com/topic/261440-syntax-error-unexpected-t_elseif/#findComment-1339673 Share on other sites More sharing options...
NLT Posted April 22, 2012 Author Share Posted April 22, 2012 You are running other statements after the preceding if but before you use elseif. elseif must come immediately after the close of the preceding if: if(condition1) { echo "foo"; }//end of if elseif(condition2) { echo "bar"; } You have something like: if(condition1) { echo "foo"; }//end of if echo "I have some stuff here after if but before elseif--I can't use elseif after this! elseif(condition2) { echo "bar"; } Thank you, I always thought you could add things in between, but nevermind x). EDIT: Fixed, thank you. Quote Link to comment https://forums.phpfreaks.com/topic/261440-syntax-error-unexpected-t_elseif/#findComment-1339680 Share on other sites More sharing options...
jcanker Posted April 22, 2012 Share Posted April 22, 2012 Nope, not between. Anything you want to run on everything should go before or after the if/elseif strings, not between them. Good luck Quote Link to comment https://forums.phpfreaks.com/topic/261440-syntax-error-unexpected-t_elseif/#findComment-1339682 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.