Jump to content

If statement running when it shouldn't


bschultz
Go to solution Solved by bschultz,

Recommended Posts

The following code ran as true on Friday at 11:45pm...and $showname did not equal anything...anyone know why?

 

if ((($dow != 'Friday' || $dow != 'Saturday') && $hour == '23' && $minute == '45') || $showname == 'livingthecountrylife')

 

This should only run on Sunday, MOnday, Tuesday, Wednesday and Thursday night at 11:45pm...or when run from command line passing the variable Showname the value of livingthecountrylife.

 

The date and time variables are set like this:

 

$year = date('Y'); // 4 digit
$month = date('m'); // with leading zeros
$date = date('d'); // with leading zeros
$dow = date('l'); // Sunday Monday Tuesday...etc
$hour = date('H'); // 24 hour with leading zeros
$minute = date('i'); // with leading zero
$now = date('Y-m-d');

 

Thanks!

Link to comment
Share on other sites

because you are using negative logic, you must complement the conditional test OR you could use true logic and complement that expression. either of the following should work (untested) -

 

if ((($dow != 'Friday' && $dow != 'Saturday') && $hour == '23' && $minute == '45') || $showname == 'livingthecountrylife')

 

if ((!($dow == 'Friday' || $dow == 'Saturday') && $hour == '23' && $minute == '45') || $showname == 'livingthecountrylife')

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.