Jump to content


Photo

If condition problem....


  • Please log in to reply
2 replies to this topic

#1 mkosmosports

mkosmosports
  • Members
  • PipPipPip
  • Advanced Member
  • 196 posts

Posted 05 October 2006 - 02:35 AM

Ive got the strangest issue and Ive spent the last few hours on it!!

Ive got this condition:

if ($group != "13" && $season <= "2005")
  {
    header('Location: error.html');
  }

This works great, but wait, there is another group variable for which I want the season variable to be able to go lower than 2005. Logically, I would try the below condition....

if ($group != "13" || $group != "14") && $season <= "2005")
  {
    header('Location: error.html');
  }

But now, the "unless the groups are NOT 13 OR 14" condition does not work anymore. The second condition is the only one that works correctly. Is there a rule where you cannot have if (NOT EQUAL or NOT EQUAL)?

Thanks for any advice....
mkosmosports

#2 Hi I Am Timbo

Hi I Am Timbo
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 05 October 2006 - 02:44 AM

if group != 13 || group != 14 is always true.  It cannot be both, therefore, it is not one of them.

You probably want an && between those as well.

#3 mkosmosports

mkosmosports
  • Members
  • PipPipPip
  • Advanced Member
  • 196 posts

Posted 05 October 2006 - 02:56 AM

ha...youre so right. how did this not occur to me..&& is the correct operator here not ||....

Thanks Timbo




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users