Newbie Problem using if statement with &&

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John

    Newbie Problem using if statement with &&

    Hello all.

    I am a PHP newbie and am having an issue using the && in an if
    statement. here is the code:

    if ($_REQUEST["frmIsEarlyBird "] == "1" && date("Y-m-d") <
    $rowWork["wEarlyBird "]) {
    die("<h1>The earlybird special has ended.</h1>");
    }

    Ok when the code runs it and both conditions are true nothing happens.

    Testing:

    $_REQUEST["frmIsEarlyBird "] is a valid form request and returns a
    string of 1 or 0 depending on what im sending.

    $rowWork["wEarlyBird "] Has a valid date in it and should validate as
    true

    If i put these if statements on the page they both work fine.

    if ($_REQUEST["frmIsEarlyBird "] == "1") {
    echo "<br><br>TRUE<b r><br>";
    } else {
    echo "<br><br>False< br><br>";
    }

    if (date("Y-m-d") < $rowWork["wEarlyBird "]) {
    echo "<br><br>TRUE<b r><br>";
    } else {
    echo "<br><br>False< br><br>";
    }

    Thanks in advance for any help
  • Jerry Stuckle

    #2
    Re: Newbie Problem using if statement with &amp;&amp;

    John wrote:
    Hello all.
    >
    I am a PHP newbie and am having an issue using the && in an if
    statement. here is the code:
    >
    if ($_REQUEST["frmIsEarlyBird "] == "1" && date("Y-m-d") <
    $rowWork["wEarlyBird "]) {
    die("<h1>The earlybird special has ended.</h1>");
    }
    >
    Ok when the code runs it and both conditions are true nothing happens.
    >
    Testing:
    >
    $_REQUEST["frmIsEarlyBird "] is a valid form request and returns a
    string of 1 or 0 depending on what im sending.
    >
    $rowWork["wEarlyBird "] Has a valid date in it and should validate as
    true
    >
    If i put these if statements on the page they both work fine.
    >
    if ($_REQUEST["frmIsEarlyBird "] == "1") {
    echo "<br><br>TRUE<b r><br>";
    } else {
    echo "<br><br>False< br><br>";
    }
    >
    if (date("Y-m-d") < $rowWork["wEarlyBird "]) {
    echo "<br><br>TRUE<b r><br>";
    } else {
    echo "<br><br>False< br><br>";
    }
    >
    Thanks in advance for any help
    When things like this fail, a good first step is to echo the values
    involved.

    For instance, right now, what do you have in $_REQUEST["frmIsEarlyBird "]
    and $rowWork["wEarlyBird "]? Are you getting what you think you should
    be getting from date("Y-m-d")? Also - is $_REQUEST["frmIsEarlyBird "]
    equal to "1" or 1? They are two different values.

    Also, $_REQUEST is generally not a good thing to use, If it's coming
    from a POSTed forum, use $_POST. If it's in the URL, use $_GET.

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • John

      #3
      Re: Newbie Problem using if statement with &amp;&amp;

      Yeah I have tested the vslues and they are valid. As i said in the
      original post:


      Testing:

      $_REQUEST["frmIsEarlyBird "] is a valid form request and returns a
      string of 1 or 0 depending on what im sending.

      $rowWork["wEarlyBird "] Has a valid date in it and should validate as
      true

      If i put these if statements on the page they both work fine.
      (validate as true)

      if ($_REQUEST["frmIsEarlyBird "] == "1") {
      echo "<br><br>TRUE<b r><br>";
      } else {
      echo "<br><br>False< br><br>";
      }

      if (date("Y-m-d") < $rowWork["wEarlyBird "]) {
      echo "<br><br>TRUE<b r><br>";
      } else {
      echo "<br><br>False< br><br>";
      }

      On Jun 1, 4:42 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
      John wrote:
      Hello all.
      >
      I am a PHP newbie and am having an issue using the && in an if
      statement. here is the code:
      >
      if ($_REQUEST["frmIsEarlyBird "] == "1" && date("Y-m-d") <
      $rowWork["wEarlyBird "]) {
      die("<h1>The earlybird special has ended.</h1>");
      }
      >
      Ok when the code runs it and both conditions are true nothing happens.
      >
      Testing:
      >
      $_REQUEST["frmIsEarlyBird "] is a valid form request and returns a
      string of 1 or 0 depending on what im sending.
      >
      $rowWork["wEarlyBird "] Has a valid date in it and should validate as
      true
      >
      If i put these if statements on the page they both work fine.
      >
           if ($_REQUEST["frmIsEarlyBird "] == "1") {
                echo "<br><br>TRUE<b r><br>";
           } else {
                echo "<br><br>False< br><br>";
           }
      >
           if (date("Y-m-d") < $rowWork["wEarlyBird "]) {
                echo "<br><br>TRUE<b r><br>";
           } else {
                echo "<br><br>False< br><br>";
           }
      >
      Thanks in advance for any help
      >
      When things like this fail, a good first step is to echo the values
      involved.
      >
      For instance, right now, what do you have in $_REQUEST["frmIsEarlyBird "]
      and $rowWork["wEarlyBird "]?  Are you getting what you think you should
      be getting from date("Y-m-d")?  Also - is $_REQUEST["frmIsEarlyBird "]
      equal to "1" or 1?  They are two different values.
      >
      Also, $_REQUEST is generally not a good thing to use,  If it's coming
      from a POSTed forum, use $_POST.  If it's in the URL, use $_GET.
      >
      --
      =============== ===
      Remove the "x" from my email address
      Jerry Stuckle
      JDS Computer Training Corp.
      jstuck...@attgl obal.net
      =============== ===- Hide quoted text -
      >
      - Show quoted text -

      Comment

      • Jerry Stuckle

        #4
        Re: Newbie Problem using if statement with &amp;&amp;

        John wrote:
        On Jun 1, 4:42 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
        >John wrote:
        >>Hello all.
        >>I am a PHP newbie and am having an issue using the && in an if
        >>statement. here is the code:
        >>if ($_REQUEST["frmIsEarlyBird "] == "1" && date("Y-m-d") <
        >>$rowWork["wEarlyBird "]) {
        >>die("<h1>Th e earlybird special has ended.</h1>");
        >>}
        >>Ok when the code runs it and both conditions are true nothing happens.
        >>Testing:
        >>$_REQUEST["frmIsEarlyBird "] is a valid form request and returns a
        >>string of 1 or 0 depending on what im sending.
        >>$rowWork["wEarlyBird "] Has a valid date in it and should validate as
        >>true
        >>If i put these if statements on the page they both work fine.
        >> if ($_REQUEST["frmIsEarlyBird "] == "1") {
        >> echo "<br><br>TRUE<b r><br>";
        >> } else {
        >> echo "<br><br>False< br><br>";
        >> }
        >> if (date("Y-m-d") < $rowWork["wEarlyBird "]) {
        >> echo "<br><br>TRUE<b r><br>";
        >> } else {
        >> echo "<br><br>False< br><br>";
        >> }
        >>Thanks in advance for any help
        >When things like this fail, a good first step is to echo the values
        >involved.
        >>
        >For instance, right now, what do you have in $_REQUEST["frmIsEarlyBird "]
        >and $rowWork["wEarlyBird "]? Are you getting what you think you should
        >be getting from date("Y-m-d")? Also - is $_REQUEST["frmIsEarlyBird "]
        >equal to "1" or 1? They are two different values.
        >>
        >Also, $_REQUEST is generally not a good thing to use, If it's coming
        >from a POSTed forum, use $_POST. If it's in the URL, use $_GET.
        >>
        >--
        >============== ====
        >Remove the "x" from my email address
        >Jerry Stuckle
        >JDS Computer Training Corp.
        >jstuck...@attg lobal.net
        >============== ====- Hide quoted text -
        >>
        >- Show quoted text -
        >
        Yeah I have tested the vslues and they are valid. As i said in the
        original post:
        >
        >
        Testing:
        >
        $_REQUEST["frmIsEarlyBird "] is a valid form request and returns a
        string of 1 or 0 depending on what im sending.
        >
        $rowWork["wEarlyBird "] Has a valid date in it and should validate as
        true
        >
        If i put these if statements on the page they both work fine.
        (validate as true)
        >
        if ($_REQUEST["frmIsEarlyBird "] == "1") {
        echo "<br><br>TRUE<b r><br>";
        } else {
        echo "<br><br>False< br><br>";
        }
        >
        if (date("Y-m-d") < $rowWork["wEarlyBird "]) {
        echo "<br><br>TRUE<b r><br>";
        } else {
        echo "<br><br>False< br><br>";
        }
        >
        (Top posting fixed)

        Well, obviously something is not as you describe, because '&&' has a
        lower priority than either '==' or '<', which is why I asked you to
        verify this. It's either the data or the statement you supplied doesn't
        match what you have in your code. I'm just trying to eliminate
        possibilities.

        P.S. Please don't top post. Thanks.

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • Jerry Stuckle

          #5
          Re: Newbie Problem using if statement with &amp;&amp;

          John wrote:
          On Jun 1, 4:42 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
          >John wrote:
          >>Hello all.
          >>I am a PHP newbie and am having an issue using the && in an if
          >>statement. here is the code:
          >>if ($_REQUEST["frmIsEarlyBird "] == "1" && date("Y-m-d") <
          >>$rowWork["wEarlyBird "]) {
          >>die("<h1>Th e earlybird special has ended.</h1>");
          >>}
          >>Ok when the code runs it and both conditions are true nothing happens.
          >>Testing:
          >>$_REQUEST["frmIsEarlyBird "] is a valid form request and returns a
          >>string of 1 or 0 depending on what im sending.
          >>$rowWork["wEarlyBird "] Has a valid date in it and should validate as
          >>true
          >>If i put these if statements on the page they both work fine.
          >> if ($_REQUEST["frmIsEarlyBird "] == "1") {
          >> echo "<br><br>TRUE<b r><br>";
          >> } else {
          >> echo "<br><br>False< br><br>";
          >> }
          >> if (date("Y-m-d") < $rowWork["wEarlyBird "]) {
          >> echo "<br><br>TRUE<b r><br>";
          >> } else {
          >> echo "<br><br>False< br><br>";
          >> }
          >>Thanks in advance for any help
          >When things like this fail, a good first step is to echo the values
          >involved.
          >>
          >For instance, right now, what do you have in $_REQUEST["frmIsEarlyBird "]
          >and $rowWork["wEarlyBird "]? Are you getting what you think you should
          >be getting from date("Y-m-d")? Also - is $_REQUEST["frmIsEarlyBird "]
          >equal to "1" or 1? They are two different values.
          >>
          >Also, $_REQUEST is generally not a good thing to use, If it's coming
          >from a POSTed forum, use $_POST. If it's in the URL, use $_GET.
          >>
          >--
          >============== ====
          >Remove the "x" from my email address
          >Jerry Stuckle
          >JDS Computer Training Corp.
          >jstuck...@attg lobal.net
          >============== ====- Hide quoted text -
          >>
          >- Show quoted text -
          >
          Yeah I have tested the vslues and they are valid. As i said in the
          original post:
          >
          >
          Testing:
          >
          $_REQUEST["frmIsEarlyBird "] is a valid form request and returns a
          string of 1 or 0 depending on what im sending.
          >
          $rowWork["wEarlyBird "] Has a valid date in it and should validate as
          true
          >
          If i put these if statements on the page they both work fine.
          (validate as true)
          >
          if ($_REQUEST["frmIsEarlyBird "] == "1") {
          echo "<br><br>TRUE<b r><br>";
          } else {
          echo "<br><br>False< br><br>";
          }
          >
          if (date("Y-m-d") < $rowWork["wEarlyBird "]) {
          echo "<br><br>TRUE<b r><br>";
          } else {
          echo "<br><br>False< br><br>";
          }
          >
          (Top posting fixed)

          Well, obviously something is not as you describe, because '&&' has a
          lower priority than either '==' or '<', which is why I asked you to
          verify this. It's either the data or the statement you supplied doesn't
          match what you have in your code. I'm just trying to eliminate
          possibilities.

          P.S. Please don't top post. Thanks.

          --
          =============== ===
          Remove the "x" from my email address
          Jerry Stuckle
          JDS Computer Training Corp.
          jstucklex@attgl obal.net
          =============== ===

          Comment

          • John

            #6
            Re: Newbie Problem using if statement with &amp;&amp;

            On Jun 1, 8:10 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
            John wrote:
            On Jun 1, 4:42 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
            John wrote:
            >Hello all.
            >I am a PHP newbie and am having an issue using the && in an if
            >statement. here is the code:
            >if ($_REQUEST["frmIsEarlyBird "] == "1" && date("Y-m-d") <
            >$rowWork["wEarlyBird "]) {
            >die("<h1>The earlybird special has ended.</h1>");
            >}
            >Ok when the code runs it and both conditions are true nothing happens.
            >Testing:
            >$_REQUEST["frmIsEarlyBird "] is a valid form request and returns a
            >string of 1 or 0 depending on what im sending.
            >$rowWork["wEarlyBird "] Has a valid date in it and should validate as
            >true
            >If i put these if statements on the page they both work fine.
            >     if ($_REQUEST["frmIsEarlyBird "] == "1") {
            >          echo "<br><br>TRUE<b r><br>";
            >     } else {
            >          echo "<br><br>False< br><br>";
            >     }
            >     if (date("Y-m-d") < $rowWork["wEarlyBird "]) {
            >          echo "<br><br>TRUE<b r><br>";
            >     } else {
            >          echo "<br><br>False< br><br>";
            >     }
            >Thanks in advance for any help
            When things like this fail, a good first step is to echo the values
            involved.
            >
            For instance, right now, what do you have in $_REQUEST["frmIsEarlyBird "]
            and $rowWork["wEarlyBird "]?  Are you getting what you think you should
            be getting from date("Y-m-d")?  Also - is $_REQUEST["frmIsEarlyBird "]
            equal to "1" or 1?  They are two different values.
            >
            Also, $_REQUEST is generally not a good thing to use,  If it's coming
            from a POSTed forum, use $_POST.  If it's in the URL, use $_GET.
            >
            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstuck...@attgl obal.net
            =============== ===- Hide quoted text -
            >
            - Show quoted text -
            >
             Yeah I have tested the vslues and they are valid. As i said in the
             original post:
             >
             >
             Testing:
             >
             $_REQUEST["frmIsEarlyBird "] is a valid form request and returns a
             string of 1 or 0 depending on what im sending.
             >
             $rowWork["wEarlyBird "] Has a valid date in it and should validate as
             true
             >
             If i put these if statements on the page they both work fine.
             (validate as true)
             >
                  if ($_REQUEST["frmIsEarlyBird "] == "1") {
                       echo "<br><br>TRUE<b r><br>";
                  } else {
                       echo "<br><br>False< br><br>";
                  }
             >
                  if (date("Y-m-d") < $rowWork["wEarlyBird "]) {
                       echo "<br><br>TRUE<b r><br>";
                  } else {
                       echo "<br><br>False< br><br>";
                  }
             >
            >
            (Top posting fixed)
            >
            Well, obviously something is not as you describe, because '&&' has a
            lower priority than either '==' or '<', which is why I asked you to
            verify this.  It's either the data or the statement you supplied doesn't
            match what you have in your code.  I'm just trying to eliminate
            possibilities.
            >
            P.S. Please don't top post.  Thanks.
            >
            --
            =============== ===
            Remove the "x" from my email address
            Jerry Stuckle
            JDS Computer Training Corp.
            jstuck...@attgl obal.net
            =============== ===- Hide quoted text -
            >
            - Show quoted text -
            Sorry bout top posting im new to this group thing as well as php.
            Thanks for trying to help me. the code below is an exact paste from
            the page. I have the first two if statements there to test the
            variables. When the code runs I see TRUE TRUE and thats it the die
            never runs. It is my understanding that I am trying to say in my
            statement that if $_REQUEST["frmIsEarlyBird "] == "1" is true AND
            date("Y-m-d") < $rowWork["wEarlyBird "] is true run the die. I dont
            understand why the first two if statetments would each display true
            but the third not run.

            if ($_REQUEST["frmIsEarlyBird "] == "1") {
            echo "<br><br>TRUE<b r><br>";
            } else {
            echo "<br><br>False< br><br>";
            }

            if (date("Y-m-d") < $rowWork["wEarlyBird "]) {
            echo "<br><br>TRUE<b r><br>";
            } else {
            echo "<br><br>False< br><br>";
            }

            if ($_REQUEST["frmIsEarlyBird "] == "1" && date("Y-m-d") <
            $rowWork["wEarlyBird "]) {
            die("<h1>The earlybird special has ended.</h1>");
            }

            Comment

            • Rik Wasmus

              #7
              Re: Newbie Problem using if statement with &amp;&amp;

              On Mon, 02 Jun 2008 06:30:51 +0200, John <JohnMay1248@gm ail.comwrote:
              On Jun 1, 8:10 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
              >John wrote:
              On Jun 1, 4:42 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
              >John wrote:
              >>Hello all.
              >>I am a PHP newbie and am having an issue using the && in an if
              >>statement. here is the code:
              >>if ($_REQUEST["frmIsEarlyBird "] == "1" && date("Y-m-d") <
              >>$rowWork["wEarlyBird "]) {
              >>die("<h1>Th e earlybird special has ended.</h1>");
              >>}
              >>Ok when the code runs it and both conditions are true nothing
              >happens.
              >>Testing:
              >>$_REQUEST["frmIsEarlyBird "] is a valid form request and returns a
              >>string of 1 or 0 depending on what im sending.
              >>$rowWork["wEarlyBird "] Has a valid date in it and should validate as
              >>true
              >>If i put these if statements on the page they both work fine.
              >>     if ($_REQUEST["frmIsEarlyBird "] == "1") {
              >>          echo "<br><br>TRUE<b r><br>";
              >>     } else {
              >>          echo "<br><br>False< br><br>";
              >>     }
              >>     if (date("Y-m-d") < $rowWork["wEarlyBird "]) {
              >>          echo "<br><br>TRUE<b r><br>";
              >>     } else {
              >>          echo "<br><br>False< br><br>";
              >>     }
              >>Thanks in advance for any help
              >When things like this fail, a good first step is to echo the values
              >involved.
              >>
              >For instance, right now, what do you have in
              >$_REQUEST["frmIsEarlyBird "]
              >and $rowWork["wEarlyBird "]?  Are you getting what you think you
              >should
              >be getting from date("Y-m-d")?  Also - is $_REQUEST["frmIsEarlyBird "]
              >equal to "1" or 1?  They are two different values.
              >>
              >Also, $_REQUEST is generally not a good thing to use,  If it's coming
              >from a POSTed forum, use $_POST.  If it's in the URL, use $_GET.
              >>
              >--
              >============== ====
              >Remove the "x" from my email address
              >Jerry Stuckle
              >JDS Computer Training Corp.
              >jstuck...@attg lobal.net
              >============== ====- Hide quoted text -
              >>
              >- Show quoted text -
              >>
              > Yeah I have tested the vslues and they are valid. As i said in the
              > original post:
              > >
              > >
              > Testing:
              > >
              > $_REQUEST["frmIsEarlyBird "] is a valid form request and returns a
              > string of 1 or 0 depending on what im sending.
              > >
              > $rowWork["wEarlyBird "] Has a valid date in it and should validate as
              > true
              > >
              > If i put these if statements on the page they both work fine.
              > (validate as true)
              > >
              >      if ($_REQUEST["frmIsEarlyBird "] == "1") {
              >           echo "<br><br>TRUE<b r><br>";
              >      } else {
              >           echo "<br><br>False< br><br>";
              >      }
              > >
              >      if (date("Y-m-d") < $rowWork["wEarlyBird "]) {
              >           echo "<br><br>TRUE<b r><br>";
              >      } else {
              >           echo "<br><br>False< br><br>";
              >      }
              > >
              >>
              >(Top posting fixed)
              >>
              >Well, obviously something is not as you describe, because '&&' has a
              >lower priority than either '==' or '<', which is why I asked you to
              >verify this.  It's either the data or the statement you supplied doesn't
              >match what you have in your code.  I'm just trying to eliminate
              >possibilitie s.
              >>
              >
              Sorry bout top posting im new to this group thing as well as php.
              Thanks for trying to help me. the code below is an exact paste from
              the page. I have the first two if statements there to test the
              variables. When the code runs I see TRUE TRUE and thats it the die
              never runs. It is my understanding that I am trying to say in my
              statement that if $_REQUEST["frmIsEarlyBird "] == "1" is true AND
              date("Y-m-d") < $rowWork["wEarlyBird "] is true run the die. I dont
              understand why the first two if statetments would each display true
              but the third not run.
              >
              if ($_REQUEST["frmIsEarlyBird "] == "1") {
              echo "<br><br>TRUE<b r><br>";
              } else {
              echo "<br><br>False< br><br>";
              }
              >
              if (date("Y-m-d") < $rowWork["wEarlyBird "]) {
              echo "<br><br>TRUE<b r><br>";
              } else {
              echo "<br><br>False< br><br>";
              }
              >
              if ($_REQUEST["frmIsEarlyBird "] == "1" && date("Y-m-d") <
              $rowWork["wEarlyBird "]) {
              die("<h1>The earlybird special has ended.</h1>");
              }
              If that's the actual code, with nothing in between that can alter either
              of the variables, I'm thoroughly puzzled. 100% sure you're not misspelling
              one of the variable names? And have you enabled display_errors and set
              error_reporting to E_ALL | E_STRICT ?
              --
              Rik Wasmus
              ....spamrun finished

              Comment

              • thelma@uwm.edu

                #8
                Re: Newbie Problem using if statement with &amp;&amp;

                John <JohnMay1248@gm ail.comwrote:
                : I dont
                : understand why the first two if statetments would each display true
                : but the third not run.

                : if ($_REQUEST["frmIsEarlyBird "] == "1") {
                : echo "<br><br>TRUE<b r><br>";
                : } else {
                : echo "<br><br>False< br><br>";
                : }

                : if (date("Y-m-d") < $rowWork["wEarlyBird "]) {
                : echo "<br><br>TRUE<b r><br>";
                : } else {
                : echo "<br><br>False< br><br>";
                : }

                : if ($_REQUEST["frmIsEarlyBird "] == "1" && date("Y-m-d") <
                : $rowWork["wEarlyBird "]) {
                : die("<h1>The earlybird special has ended.</h1>");
                : }


                What happens if you replace your last statement with this one?

                if ($_REQUEST["frmIsEarlyBird "] == "1" && date("Y-m-d") <
                $rowWork["wEarlyBird "]) {
                echo 'hereiam<br/>';
                }
                --thelma
                [with no real idea of what's going on]

                Comment

                • Captain Paralytic

                  #9
                  Re: Newbie Problem using if statement with &amp;&amp;

                  On 2 Jun, 04:30, John <JohnMay1...@gm ail.comwrote:
                  On Jun 1, 8:10 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
                  >
                  >
                  >
                  John wrote:
                  On Jun 1, 4:42 pm, Jerry Stuckle <jstuck...@attg lobal.netwrote:
                  >John wrote:
                  >>Hello all.
                  >>I am a PHP newbie and am having an issue using the && in an if
                  >>statement. here is the code:
                  >>if ($_REQUEST["frmIsEarlyBird "] == "1" && date("Y-m-d") <
                  >>$rowWork["wEarlyBird "]) {
                  >>die("<h1>Th e earlybird special has ended.</h1>");
                  >>}
                  >>Ok when the code runs it and both conditions are true nothing happens.
                  >>Testing:
                  >>$_REQUEST["frmIsEarlyBird "] is a valid form request and returns a
                  >>string of 1 or 0 depending on what im sending.
                  >>$rowWork["wEarlyBird "] Has a valid date in it and should validate as
                  >>true
                  >>If i put these if statements on the page they both work fine.
                  >> if ($_REQUEST["frmIsEarlyBird "] == "1") {
                  >> echo "<br><br>TRUE<b r><br>";
                  >> } else {
                  >> echo "<br><br>False< br><br>";
                  >> }
                  >> if (date("Y-m-d") < $rowWork["wEarlyBird "]) {
                  >> echo "<br><br>TRUE<b r><br>";
                  >> } else {
                  >> echo "<br><br>False< br><br>";
                  >> }
                  >>Thanks in advance for any help
                  >When things like this fail, a good first step is to echo the values
                  >involved.
                  >
                  >For instance, right now, what do you have in $_REQUEST["frmIsEarlyBird "]
                  >and $rowWork["wEarlyBird "]? Are you getting what you think you should
                  >be getting from date("Y-m-d")? Also - is $_REQUEST["frmIsEarlyBird "]
                  >equal to "1" or 1? They are two different values.
                  >
                  >Also, $_REQUEST is generally not a good thing to use, If it's coming
                  >from a POSTed forum, use $_POST. If it's in the URL, use $_GET.
                  >
                  >--
                  >============== ====
                  >Remove the "x" from my email address
                  >Jerry Stuckle
                  >JDS Computer Training Corp.
                  >jstuck...@attg lobal.net
                  >============== ====- Hide quoted text -
                  >
                  >- Show quoted text -
                  >
                  Yeah I have tested the vslues and they are valid. As i said in the
                  original post:
                  >
                  >
                  Testing:
                  >
                  $_REQUEST["frmIsEarlyBird "] is a valid form request and returns a
                  string of 1 or 0 depending on what im sending.
                  >
                  $rowWork["wEarlyBird "] Has a valid date in it and should validate as
                  true
                  >
                  If i put these if statements on the page they both work fine.
                  (validate as true)
                  >
                  if ($_REQUEST["frmIsEarlyBird "] == "1") {
                  echo "<br><br>TRUE<b r><br>";
                  } else {
                  echo "<br><br>False< br><br>";
                  }
                  >
                  if (date("Y-m-d") < $rowWork["wEarlyBird "]) {
                  echo "<br><br>TRUE<b r><br>";
                  } else {
                  echo "<br><br>False< br><br>";
                  }
                  >
                  >
                  (Top posting fixed)
                  >
                  Well, obviously something is not as you describe, because '&&' has a
                  lower priority than either '==' or '<', which is why I asked you to
                  verify this. It's either the data or the statement you supplied doesn't
                  match what you have in your code. I'm just trying to eliminate
                  possibilities.
                  >
                  P.S. Please don't top post. Thanks.
                  >
                  --
                  =============== ===
                  Remove the "x" from my email address
                  Jerry Stuckle
                  JDS Computer Training Corp.
                  jstuck...@attgl obal.net
                  =============== ===- Hide quoted text -
                  >
                  - Show quoted text -
                  >
                  Sorry bout top posting im new to this group thing as well as php.
                  Thanks for trying to help me. the code below is an exact paste from
                  the page. I have the first two if statements there to test the
                  variables. When the code runs I see TRUE TRUE and thats it the die
                  never runs. It is my understanding that I am trying to say in my
                  statement that if $_REQUEST["frmIsEarlyBird "] == "1" is true AND
                  date("Y-m-d") < $rowWork["wEarlyBird "] is true run the die. I dont
                  understand why the first two if statetments would each display true
                  but the third not run.
                  >
                  if ($_REQUEST["frmIsEarlyBird "] == "1") {
                  echo "<br><br>TRUE<b r><br>";
                  } else {
                  echo "<br><br>False< br><br>";
                  }
                  >
                  if (date("Y-m-d") < $rowWork["wEarlyBird "]) {
                  echo "<br><br>TRUE<b r><br>";
                  } else {
                  echo "<br><br>False< br><br>";
                  }
                  >
                  if ($_REQUEST["frmIsEarlyBird "] == "1" && date("Y-m-d") <
                  $rowWork["wEarlyBird "]) {
                  die("<h1>The earlybird special has ended.</h1>");
                  }
                  First a hint. Only use double quotes, if you want to perform variable
                  substitution within a string. Otherwise, try to use single quotes.

                  Now, when I get a problem like this, I tend to echo out all the values
                  and all the intermediate results. So please replace your code with
                  this and then post the output here:

                  echo 'frmIsEarlyBird ='.$_REQUEST['frmIsEarlyBird].'=<br />';
                  echo 'date='.date('Y-m-d').'=<br />';
                  echo 'wEarlyBird='.$ rowWork['wEarlyBird'].'=<br />';
                  echo '($_REQUEST["frmIsEarlyBird "] == \'1\')='.
                  ($_REQUEST['frmIsEarlyBird '] == '1').'=<br />';
                  echo '(date(\'Y-m-d\') < $rowWork[\'wEarlyBird\'])='.(date(\'Y-m-d\')
                  < $rowWork[\'wEarlyBird\']).'=';
                  echo '&&='.($_REQUES T['frmIsEarlyBird '] == '1' && date(\'Y-m-d\') <
                  $rowWork[\'wEarlyBird\']).'=';


                  if ($_REQUEST['frmIsEarlyBird '] == '1' && date('Y-m-d') <
                  $rowWork['wEarlyBird']) {
                  die('<h1>The earlybird special has ended.</h1>');

                  }

                  Comment

                  • Peter H. Coffin

                    #10
                    Re: Newbie Problem using if statement with &amp;&amp;

                    On Sun, 1 Jun 2008 21:30:51 -0700 (PDT), John wrote:
                    Sorry bout top posting im new to this group thing as well as php.
                    Thanks for trying to help me. the code below is an exact paste from
                    the page. I have the first two if statements there to test the
                    variables. When the code runs I see TRUE TRUE and thats it the die
                    never runs. It is my understanding that I am trying to say in my
                    statement that if $_REQUEST["frmIsEarlyBird "] == "1" is true AND
                    date("Y-m-d") < $rowWork["wEarlyBird "] is true run the die. I dont
                    understand why the first two if statetments would each display true
                    but the third not run.
                    >
                    if ($_REQUEST["frmIsEarlyBird "] == "1") {
                    echo "<br><br>TRUE<b r><br>";
                    } else {
                    echo "<br><br>False< br><br>";
                    }
                    >
                    if (date("Y-m-d") < $rowWork["wEarlyBird "]) {
                    echo "<br><br>TRUE<b r><br>";
                    } else {
                    echo "<br><br>False< br><br>";
                    }
                    >
                    if ($_REQUEST["frmIsEarlyBird "] == "1" && date("Y-m-d") <
                    > $rowWork["wEarlyBird "]) {
                    die("<h1>The earlybird special has ended.</h1>");
                    }
                    Are you 100% sure that this is a problem with the && operator and not a
                    problem with the fact that your < maybe should be a ? 'Cause that
                    LOOKS like it's testing that the current time is BEFORE the "wEarlyBird "
                    thing, not after it.

                    --
                    Any research done on how to efficiently use computers has been long lost
                    in the mad rush to upgrade systems to do things that aren't needed by
                    people who don't understand what they are really supposed to do with them.
                    -- Graham Reed

                    Comment

                    Working...