Jump to content

Archived

This topic is now archived and is closed to further replies.

mkosmosports

If condition problem....

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.