meltingpoint Posted January 28, 2012 Share Posted January 28, 2012 This works: if($ABC == 'Yes' and $X != $Y){ echo "Error"; exit(); } I need to evaluate one more set of variables in this statement like so; This does not work: if($ABC == 'Yes' and $X != $Y or $Z != $Y){ echo "Error"; exit(); } So basically I need to echo an error if $ABC == Yes and both $X and $Z do not equal $Y If gives an error because it is obviously not correct. I do not know how to make it correct. Any suggestions? Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted January 28, 2012 Share Posted January 28, 2012 //fixed with || which will return both true and false and just not false if($ABC == 'Yes' and $X != $Y || $Z != $Y){ echo "Error"; exit(); } Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted January 28, 2012 Share Posted January 28, 2012 You had the logic you need written out already: $ABC == Yes and both $X and $Z do not equal $Y . . . if( $ABC == 'Yes' && $X != $Y && $Z != $Y) { Edit: fixed tags . . . Quote Link to comment Share on other sites More sharing options...
meltingpoint Posted January 28, 2012 Author Share Posted January 28, 2012 Thanks- stared too long at the problem. Cheers- Quote Link to comment 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.