ChrisMartino Posted January 18, 2011 Share Posted January 18, 2011 Hey there, Now usually after a while I can always solve bugs with my code but this one really has me at a halt here. So basically I have a function that returns true if the accounts username = demo and false if it doesn't but the following if statement returns true and executes the code every time regardless of the returned value of the function like so: if(isset($_POST['server_start']) or isset($_POST['server_stop']) or isset($_POST['server_restart']) && $Class['Account']->is_demo_account($_SESSION['account_id']) == false) Now if I run the following code right above that: if($Class['Account']->is_demo_account($_SESSION['account_id']) == false) echo "it isn't a demo account."; else echo "it is a demo account."; It will echo "it is a demo account" correctly. Now can somebody please tell me why the if statement with the post values in always return true. Thanks for your time! Quote Link to comment https://forums.phpfreaks.com/topic/224888-comparison-issues-if-statement/ Share on other sites More sharing options...
Pikachu2000 Posted January 18, 2011 Share Posted January 18, 2011 Are you trying to get a TRUE evaluation: if (any one or more of the first 3 conditions) AND (last condition) ? Quote Link to comment https://forums.phpfreaks.com/topic/224888-comparison-issues-if-statement/#findComment-1161575 Share on other sites More sharing options...
ChrisMartino Posted January 18, 2011 Author Share Posted January 18, 2011 Are you trying to get a TRUE evaluation: if (any one or more of the first 3 conditions) AND (last condition) ? Yea I'm trying so if any of the first 3 conditions are set and the last condition is false. So E.G if it isn't the demo account. Quote Link to comment https://forums.phpfreaks.com/topic/224888-comparison-issues-if-statement/#findComment-1161585 Share on other sites More sharing options...
Maq Posted January 18, 2011 Share Posted January 18, 2011 You need parenthesis around the first 3 ORs for that to be true. Quote Link to comment https://forums.phpfreaks.com/topic/224888-comparison-issues-if-statement/#findComment-1161588 Share on other sites More sharing options...
ChrisMartino Posted January 18, 2011 Author Share Posted January 18, 2011 You need parenthesis around the first 3 ORs for that to be true. Thanks worked Quote Link to comment https://forums.phpfreaks.com/topic/224888-comparison-issues-if-statement/#findComment-1161614 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.