Probably a stupid question - if statement...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Tim Mousel
    Senior Member
    • May 2000
    • 281
    • 5.0.0

    Probably a stupid question - if statement...

    Hi,

    Why in the world won't this work?

    PHP Code:
    if (($area != 281) || ($area != 713)) {
    echo 
    "area is not equal to 281 or 713. area is equal to $area.";
    exit;

    I know it's a very simple statement but I can't figure out how to make it work. When I print out the $area variable it is correct, so I know it is being passed.

    Thanks,

    Tim
    Five Star Review Script - Add reviews to your website!
    Mixed Martial Arts - Houston MMA Training
    Women's Self-Defense - Courses and DVDs available
  • Mark Hensler
    Senior Member
    • Feb 2001
    • 570

    #2
    that statement will always be true because this one is always false (well, as long as we don't get into fuzzy logic ):
    if (($area == 281) && ($area == 713))

    Anyway, what you want is this:
    if (($area != 281) && ($area != 713)) {

    Comment

    • Tim Mousel
      Senior Member
      • May 2000
      • 281
      • 5.0.0

      #3
      Duh! I was stuck in a mental block....I knew it was a stupid question! Thank you for taking the time to straighten me out!

      Much appreciated!

      Tim
      Five Star Review Script - Add reviews to your website!
      Mixed Martial Arts - Houston MMA Training
      Women's Self-Defense - Courses and DVDs available

      Comment

      widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
      Working...
      😀
      😂
      🥰
      😘
      🤢
      😎
      😞
      😡
      👍
      👎