Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6019989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:30:07+00:00 2026-05-23T03:30:07+00:00

I am having trouble with my IF statement, it is always TRUE although this

  • 0

I am having trouble with my IF statement, it is always TRUE although this is incorrect. I’m using an OR operator as there are two possible scenarios I want to capture in the IF statement.

The array string ad_status is “1” but using the below -3 is returned, I’m expecting the IF to be FALSE. If I remove the OR and second statement from the IF, the result of the IF is correct.

What have I done wrong? Thanks.

    if(($getadstatus['ad_status'] != "1" || $getadstatus['ad_status'] != "4"))
    {
        return -3;
        exit;
    }

Additional:
What I want to do is exit the function (not seen in full here) if ad_status does not equal 1 or 4. If it equals any other value other than 1 or 4, the IF statement should return TRUE and exit.
ad_status could be any value from 0 to 4.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:30:08+00:00Added an answer on May 23, 2026 at 3:30 am

    What you are saying is that any value that is not 1 OR is not 4 should return true.

    For ‘1’ you get the statement

    if( 1 != 1 || 1 != 4)
    

    which translates to

    if( false || true )
    

    which is ofcourse true.

    What you need is:

    if(!($value == 1 || $value==4))
    

    which is the same as (de Morgan’s law)

    if($value != 1 && $value != 4)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having trouble with using an IF statement within this sql-server query. What I
I am having trouble running this simple statement in the IDLE prompt. if True:
I am having trouble constructing a single XPath statement to return two different sets
I'm having some trouble with this statement, owing no doubt to my ignorance of
I am having trouble with the following SQL statement. I have had this issue
I'm having trouble with Microsoft Access 2003, it's complaining about this statement: select cardnr
Hey guys i want to execute my SQL statement but im having synatx trouble,
I'm having trouble trying to define the SQL query for this table: There's a
I'm having trouble finding a simple statement to skip the duplicates for this recursive
I’m making an ios application and am having trouble using a switch statement to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.