Jump to content

Recommended Posts

I'm basically just trying to say if accounttyperaw is not equal to zero or 1 do something

I think you want to use &&. 

 

If $news['accounttyperaw'] is 0, then the second condition is true, if $news['accounttyperaw'] is 1, then the first condition is true, if $news['accounttyperaw'] is neither 0 or 1, then they are both true.  So your IF block will always result in TRUE.

Link to comment
https://forums.phpfreaks.com/topic/234086-if-syntax/#findComment-1203159
Share on other sites

I'm basically just trying to say if accounttyperaw is not equal to zero or 1 do something

 

Using your words directly, it should do what you want, although, you don't need those extra set of parenthesis around each clause.

 

<?php

if (($news['accounttyperaw'] !== 0) || ($news['accounttyperaw'] !== 1))
// Can be:
if ($news['accounttyperaw'] !== 0 || $news['accounttyperaw'] !== 1)

 

If you want to do two different things for each clause, I would do:

<?php

if ($news['accounttyperaw'] !== 0) {
  // do something
} else {
if($news['accounttyperaw'] !== 1) {
    // do something else
  }
}

Link to comment
https://forums.phpfreaks.com/topic/234086-if-syntax/#findComment-1203222
Share on other sites

$a != $b Not equal TRUE if $a is not equal to $b after type juggling.

 

<?php

if (($news['accounttyperaw'] !== 0) || ($news['accounttyperaw'] !== 1))
// Can be:
if ($news['accounttyperaw'] !== 0 || $news['accounttyperaw'] !== 1)
]

 

should be !=  with one 'equal' sign i think

 

<?php

if (($news['accounttyperaw'] != 0) || ($news['accounttyperaw'] !== 1))
// Can be:
if ($news['accounttyperaw'] != 0 || $news['accounttyperaw'] !== 1)
]

Link to comment
https://forums.phpfreaks.com/topic/234086-if-syntax/#findComment-1203237
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.