cloudll Posted March 6, 2012 Share Posted March 6, 2012 I am using the following request on my site (index.php) $compass = $_REQUEST['compass']; I wanted to use an if statement to echo an error message if $compass was anything other than north,east,south or west. However the code im using is constantly displaying the error message even when /index.php?compass=north etc. Can anyone see what I have done wrong? if (($compass != "north") || ($compass != "east") || ($compass != "south") || ($compass != "west")) { echo '<strong>Stop cheating!</strong>'; } Link to comment https://forums.phpfreaks.com/topic/258412-if-statement-not-working-correctly/ Share on other sites More sharing options...
requinix Posted March 6, 2012 Share Posted March 6, 2012 If $compass == "north" then it !="east", right? And if it =="east" then it !="north"... You want &&, not ||. Link to comment https://forums.phpfreaks.com/topic/258412-if-statement-not-working-correctly/#findComment-1324601 Share on other sites More sharing options...
cloudll Posted March 6, 2012 Author Share Posted March 6, 2012 silly me, all working now. thanks Link to comment https://forums.phpfreaks.com/topic/258412-if-statement-not-working-correctly/#findComment-1324604 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.