If, Or, And.. Won't work.. Argh! Simple I'm sure..

Discussion in 'PHP' started by stauf, Jun 28, 2007.

  1. #1
    Hey all. So far I've been thrilled with the help here and getting my stuff accomplished. Today brings something that logically should work, but isn't.. Feel free to hit me over the head when you show me something insanely simple. :rolleyes:

    
    if ($eng == "18" || "20") && ($p_sscolor == "Clear") {
    		$p_sscolor = "N/A";
    		}
    
    
    PHP:
    I've tried it with single pipes and ampersands, same results, errors..

    Thanks guys!
     
    stauf, Jun 28, 2007 IP
  2. rodney88

    rodney88 Guest

    Messages:
    480
    Likes Received:
    37
    Best Answers:
    0
    Trophy Points:
    0
    #2
    if ($eng == "18" || $eng == "20") && ($p_sscolor == "Clear")
    PHP:
     
    rodney88, Jun 28, 2007 IP
  3. stauf

    stauf Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Ok, see, thats stupid simple and makes me feel like a fool.. However.. I now get a Parse error: syntax error, unexpected T_BOOLEAN_AND.... on the If line.
     
    stauf, Jun 28, 2007 IP
  4. stauf

    stauf Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I've also tried:

    if (($eng == "18") || ($eng == "20")) && ($sscolor == "Clear")
    PHP:
    everything with single and double pipes/apersands..

    All I'm trying to do is check if $eng is 18 or 20 and $sscolor is Clear, and if so, reset $sscolor to N/A.. Perhaps I'm going about it the wrong way?
     
    stauf, Jun 28, 2007 IP
  5. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #5
    You need the if 'test' to be a single, enclosed test...

    Try:
    if ((($eng == "18") || ($eng == "20")) && ($sscolor == "Clear"))

    instead, to tie all three in together.
     
    TwistMyArm, Jun 28, 2007 IP
  6. stauf

    stauf Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Finally! The one step further I didn't think of.. plz slap me senseless... Then make sure I give you Great Thanks! :cool:
     
    stauf, Jun 28, 2007 IP