What does this mean?

Discussion in 'PHP' started by egdcltd, Nov 16, 2006.

  1. #1
    In this piece of code
    AND (store_zone = $actual_zone  ||  store_zone = 0 )
    PHP:
    what does the || mean? I think I know what it's doing, but what's the exact explanation for it please?
     
    egdcltd, Nov 16, 2006 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    || means "or". And there should probably be 2 equal signs in each condition.

    This is not the complete code, but it does "something" (that we can't see in this bit) when store_zone equals $actual_zone (which we don't know what it is either), OR if it equals 0.
     
    nico_swd, Nov 16, 2006 IP
  3. egdcltd

    egdcltd Peon

    Messages:
    691
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks. I was pretty sure that was what it was. It's part of a MySQL query that I want to change, but couldn't until I knew exactly what it was. Doesn't seem to be in PHP & MySQL for Dummies. I know what the rest of the query is doing, and what the result is.

    Can I just use OR instead?
     
    egdcltd, Nov 16, 2006 IP
  4. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #4
    Yes, you can use either || or OR. (Case.insensitive) (For MySQL I'd just use OR though)

    Now that I know it's part of a query, the single equal signs make sense too..
     
    nico_swd, Nov 16, 2006 IP
  5. egdcltd

    egdcltd Peon

    Messages:
    691
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thanks again. I didn't post the rest of the query because I understood it. Although, taking stuff out of their original context can cause problems. I really need to update my PHP manual.
     
    egdcltd, Nov 16, 2006 IP
  6. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #6
    nico_swd, Nov 16, 2006 IP
  7. egdcltd

    egdcltd Peon

    Messages:
    691
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    0
    #7
    I never seem to be able to find out what I'm looking for. Rubbish at using the search I suppose. I like the Dummies books, but mines 4 years old now.
     
    egdcltd, Nov 16, 2006 IP