Problem with AND &

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

    Problem with AND &

    I am having a problem getting AND to work. I have a MySQL database field defined as varbinary(8)
    with X00 in it. Then I have define statements with X01 in it.

    define('CERTACC ESS_MEDALS', x01);

    Then I run the data through a function

    function SecurityLevel_C heck($security_ byte, $securitylevel_ bit) {
    //AND = 1 IF BOTH are 1
    return $security_byte And $securitylevel_ bit; }

    if(SecurityLeve l_Check($record Set_cert->fields['certcode_acces s'], CERTACCESS_MEDA L) == 1) {


    No matter what the values are it always returns a 1. I've looked and looked at the docs and cannot
    figure out what I am doing wrong. I tried AND and & and both produce different but wrong results.

    PLEASE throw me a bone of a hint at what I am doing wrong.

    Thanks.

    Mike


  • noone

    #2
    Re: Problem with AND &

    Mike wrote:[color=blue]
    > I am having a problem getting AND to work. I have a MySQL database field defined as varbinary(8)
    > with X00 in it. Then I have define statements with X01 in it.
    >
    > define('CERTACC ESS_MEDALS', x01);
    >
    > Then I run the data through a function
    >
    > function SecurityLevel_C heck($security_ byte, $securitylevel_ bit) {
    > //AND = 1 IF BOTH are 1
    > return $security_byte And $securitylevel_ bit; }
    >
    > if(SecurityLeve l_Check($record Set_cert->fields['certcode_acces s'], CERTACCESS_MEDA L) == 1) {
    >
    >
    > No matter what the values are it always returns a 1. I've looked and looked at the docs and cannot
    > figure out what I am doing wrong. I tried AND and & and both produce different but wrong results.
    >
    > PLEASE throw me a bone of a hint at what I am doing wrong.
    >
    > Thanks.
    >
    > Mike
    >
    >[/color]

    Take a look at the PACK/UNPACK functions in PHP to unpack and convert
    the data to a number and do the comparison.




    M.

    Comment

    • Jerry Stuckle

      #3
      Re: Problem with AND &

      Mike wrote:[color=blue]
      > I am having a problem getting AND to work. I have a MySQL database field defined as varbinary(8)
      > with X00 in it. Then I have define statements with X01 in it.
      >
      > define('CERTACC ESS_MEDALS', x01);
      >
      > Then I run the data through a function
      >
      > function SecurityLevel_C heck($security_ byte, $securitylevel_ bit) {
      > //AND = 1 IF BOTH are 1
      > return $security_byte And $securitylevel_ bit; }
      >
      > if(SecurityLeve l_Check($record Set_cert->fields['certcode_acces s'], CERTACCESS_MEDA L) == 1) {
      >
      >
      > No matter what the values are it always returns a 1. I've looked and looked at the docs and cannot
      > figure out what I am doing wrong. I tried AND and & and both produce different but wrong results.
      >
      > PLEASE throw me a bone of a hint at what I am doing wrong.
      >
      > Thanks.
      >
      > Mike
      >
      >[/color]

      x01 is a string containing the characters "x', '0' and '1'.

      0x01 is a one (or more) byte value with the lowest order bit on (and the
      rest off).


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

      Comment

      • Mike

        #4
        Re: Problem with AND &

        I made the changes in the database records and in the defines. Same thing happens. Everything
        equates to a 1.


        "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
        news:y8ydnXXKi4 H453jenZ2dnUVZ_ sSdnZ2d@comcast .com...
        Mike wrote:[color=blue]
        > I am having a problem getting AND to work. I have a MySQL database field defined as varbinary(8)
        > with X00 in it. Then I have define statements with X01 in it.
        >
        > define('CERTACC ESS_MEDALS', x01);
        >
        > Then I run the data through a function
        >
        > function SecurityLevel_C heck($security_ byte, $securitylevel_ bit) {
        > //AND = 1 IF BOTH are 1
        > return $security_byte And $securitylevel_ bit; }
        >
        > if(SecurityLeve l_Check($record Set_cert->fields['certcode_acces s'], CERTACCESS_MEDA L) == 1) {
        >
        >
        > No matter what the values are it always returns a 1. I've looked and looked at the docs and cannot
        > figure out what I am doing wrong. I tried AND and & and both produce different but wrong results.
        >
        > PLEASE throw me a bone of a hint at what I am doing wrong.
        >
        > Thanks.
        >
        > Mike
        >
        >[/color]

        x01 is a string containing the characters "x', '0' and '1'.

        0x01 is a one (or more) byte value with the lowest order bit on (and the
        rest off).


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


        Comment

        • Jerry Stuckle

          #5
          Re: Problem with AND &amp;

          Mike wrote:[color=blue]
          > I made the changes in the database records and in the defines. Same thing happens. Everything
          > equates to a 1.
          >
          >
          > "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
          > news:y8ydnXXKi4 H453jenZ2dnUVZ_ sSdnZ2d@comcast .com...
          > Mike wrote:
          >[color=green]
          >>I am having a problem getting AND to work. I have a MySQL database field defined as varbinary(8)
          >>with X00 in it. Then I have define statements with X01 in it.
          >>
          >>define('CERTA CCESS_MEDALS', x01);
          >>
          >>Then I run the data through a function
          >>
          >>function SecurityLevel_C heck($security_ byte, $securitylevel_ bit) {
          >>//AND = 1 IF BOTH are 1
          >>return $security_byte And $securitylevel_ bit; }
          >>
          >>if(SecurityLe vel_Check($reco rdSet_cert->fields['certcode_acces s'], CERTACCESS_MEDA L) == 1) {
          >>
          >>
          >>No matter what the values are it always returns a 1. I've looked and looked at the docs and cannot
          >>figure out what I am doing wrong. I tried AND and & and both produce different but wrong results.
          >>
          >>PLEASE throw me a bone of a hint at what I am doing wrong.
          >>
          >>Thanks.
          >>
          >>Mike
          >>
          >>[/color]
          >
          >
          > x01 is a string containing the characters "x', '0' and '1'.
          >
          > 0x01 is a one (or more) byte value with the lowest order bit on (and the
          > rest off).
          >
          >[/color]

          Also, "and" is a logical and, not a bit and. Any non-zero value will be
          true.

          If you need more help, I suggest you post all the failing code - not
          just a line or two.

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

          Comment

          • Mike

            #6
            Re: Problem with AND &amp;

            I changed the function code to the following but there was no change.


            function SecurityLevel_C heck($security_ byte, $securitylevel_ bit) {
            //AND = 1 IF BOTH are 1
            $binarybyte = pack("n", $security_byte) ;
            $binarybit = pack("n", $securitylevel_ bit);
            echo "<P>SecurityLev el_Check";
            $binanswer = $security_byte AND $securitylevel_ bit;
            $binanswer2 = $binarybyte AND $binarybit;
            echo "<P>nonbin byte=".$securit y_byte." /bit=".$security level_bit." /nonbin result is ".$binanswe r;
            echo "<P>bin byte=".$binaryb yte." /bit=".$binarybi t." / bin result is ".(int)$binansw er2;
            return $security_byte AND $securitylevel_ bit; }


            I also changed all x00 to 0x00 for all definitions of hex data. What am I doing wrong?

            Results are

            SecurityLevel_C heck

            nonbin byte=xFE /bit=2 /nonbin result is xFE

            bin byte=







            "noone" <noone@nowhere. com> wrote in message news:gyeFf.2225 2$Jd.8308@newss vr25.news.prodi gy.net...
            Mike wrote:[color=blue]
            > I am having a problem getting AND to work. I have a MySQL database field defined as varbinary(8)
            > with X00 in it. Then I have define statements with X01 in it.
            >
            > define('CERTACC ESS_MEDALS', x01);
            >
            > Then I run the data through a function
            >
            > function SecurityLevel_C heck($security_ byte, $securitylevel_ bit) {
            > //AND = 1 IF BOTH are 1
            > return $security_byte And $securitylevel_ bit; }
            >
            > if(SecurityLeve l_Check($record Set_cert->fields['certcode_acces s'], CERTACCESS_MEDA L) == 1) {
            >
            >
            > No matter what the values are it always returns a 1. I've looked and looked at the docs and cannot
            > figure out what I am doing wrong. I tried AND and & and both produce different but wrong results.
            >
            > PLEASE throw me a bone of a hint at what I am doing wrong.
            >
            > Thanks.
            >
            > Mike
            >
            >[/color]

            Take a look at the PACK/UNPACK functions in PHP to unpack and convert
            the data to a number and do the comparison.




            M.




            Comment

            • Mike

              #7
              Re: Problem with AND &amp;

              Ah, that is why the result that I am getting. I just posted the function that I created.

              What is a logical AND? I thought both AND and & were. I'll have to relook at the php docs!

              Mike


              "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
              news:O--dnZ5sQK4TJXveRV n-hg@comcast.com. ..
              Mike wrote:[color=blue]
              > I made the changes in the database records and in the defines. Same thing happens. Everything
              > equates to a 1.
              >
              >
              > "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
              > news:y8ydnXXKi4 H453jenZ2dnUVZ_ sSdnZ2d@comcast .com...
              > Mike wrote:
              >[color=green]
              >>I am having a problem getting AND to work. I have a MySQL database field defined as varbinary(8)
              >>with X00 in it. Then I have define statements with X01 in it.
              >>
              >>define('CERTA CCESS_MEDALS', x01);
              >>
              >>Then I run the data through a function
              >>
              >>function SecurityLevel_C heck($security_ byte, $securitylevel_ bit) {
              >>//AND = 1 IF BOTH are 1
              >>return $security_byte And $securitylevel_ bit; }
              >>
              >>if(SecurityLe vel_Check($reco rdSet_cert->fields['certcode_acces s'], CERTACCESS_MEDA L) == 1) {
              >>
              >>
              >>No matter what the values are it always returns a 1. I've looked and looked at the docs and cannot
              >>figure out what I am doing wrong. I tried AND and & and both produce different but wrong results.
              >>
              >>PLEASE throw me a bone of a hint at what I am doing wrong.
              >>
              >>Thanks.
              >>
              >>Mike
              >>
              >>[/color]
              >
              >
              > x01 is a string containing the characters "x', '0' and '1'.
              >
              > 0x01 is a one (or more) byte value with the lowest order bit on (and the
              > rest off).
              >
              >[/color]

              Also, "and" is a logical and, not a bit and. Any non-zero value will be
              true.

              If you need more help, I suggest you post all the failing code - not
              just a line or two.

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


              Comment

              • Jerry Stuckle

                #8
                Re: Problem with AND &amp;

                Mike wrote:[color=blue]
                > Ah, that is why the result that I am getting. I just posted the function that I created.
                >
                > What is a logical AND? I thought both AND and & were. I'll have to relook at the php docs!
                >
                > Mike
                >
                >
                > "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                > news:O--dnZ5sQK4TJXveRV n-hg@comcast.com. ..
                > Mike wrote:
                >[color=green]
                >>I made the changes in the database records and in the defines. Same thing happens. Everything
                >>equates to a 1.
                >>
                >>
                >>"Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                >>news:y8ydnXXK i4H453jenZ2dnUV Z_sSdnZ2d@comca st.com...
                >>Mike wrote:
                >>
                >>[color=darkred]
                >>>I am having a problem getting AND to work. I have a MySQL database field defined as varbinary(8)
                >>>with X00 in it. Then I have define statements with X01 in it.
                >>>
                >>>define('CERT ACCESS_MEDALS', x01);
                >>>
                >>>Then I run the data through a function
                >>>
                >>>function SecurityLevel_C heck($security_ byte, $securitylevel_ bit) {
                >>>//AND = 1 IF BOTH are 1
                >>>return $security_byte And $securitylevel_ bit; }
                >>>
                >>>if(SecurityL evel_Check($rec ordSet_cert->fields['certcode_acces s'], CERTACCESS_MEDA L) == 1) {
                >>>
                >>>
                >>>No matter what the values are it always returns a 1. I've looked and looked at the docs and cannot
                >>>figure out what I am doing wrong. I tried AND and & and both produce different but wrong results.
                >>>
                >>>PLEASE throw me a bone of a hint at what I am doing wrong.
                >>>
                >>>Thanks.
                >>>
                >>>Mike
                >>>
                >>>[/color]
                >>
                >>
                >>x01 is a string containing the characters "x', '0' and '1'.
                >>
                >>0x01 is a one (or more) byte value with the lowest order bit on (and the
                >>rest off).
                >>
                >>[/color]
                >
                >
                > Also, "and" is a logical and, not a bit and. Any non-zero value will be
                > true.
                >
                > If you need more help, I suggest you post all the failing code - not
                > just a line or two.
                >[/color]

                Look at the differences between logical operators and bit operators.

                Logical operators deal with one value - true or false. Bit operators
                deal with each individual bit in the variable separately.

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

                Comment

                • Jerry Stuckle

                  #9
                  Re: Problem with AND &amp;

                  Mike wrote:[color=blue]
                  > Ah, that is why the result that I am getting. I just posted the function that I created.
                  >
                  > What is a logical AND? I thought both AND and & were. I'll have to relook at the php docs!
                  >
                  > Mike
                  >
                  >
                  > "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                  > news:O--dnZ5sQK4TJXveRV n-hg@comcast.com. ..
                  > Mike wrote:
                  >[color=green]
                  >>I made the changes in the database records and in the defines. Same thing happens. Everything
                  >>equates to a 1.
                  >>
                  >>
                  >>"Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                  >>news:y8ydnXXK i4H453jenZ2dnUV Z_sSdnZ2d@comca st.com...
                  >>Mike wrote:
                  >>
                  >>[color=darkred]
                  >>>I am having a problem getting AND to work. I have a MySQL database field defined as varbinary(8)
                  >>>with X00 in it. Then I have define statements with X01 in it.
                  >>>
                  >>>define('CERT ACCESS_MEDALS', x01);
                  >>>
                  >>>Then I run the data through a function
                  >>>
                  >>>function SecurityLevel_C heck($security_ byte, $securitylevel_ bit) {
                  >>>//AND = 1 IF BOTH are 1
                  >>>return $security_byte And $securitylevel_ bit; }
                  >>>
                  >>>if(SecurityL evel_Check($rec ordSet_cert->fields['certcode_acces s'], CERTACCESS_MEDA L) == 1) {
                  >>>
                  >>>
                  >>>No matter what the values are it always returns a 1. I've looked and looked at the docs and cannot
                  >>>figure out what I am doing wrong. I tried AND and & and both produce different but wrong results.
                  >>>
                  >>>PLEASE throw me a bone of a hint at what I am doing wrong.
                  >>>
                  >>>Thanks.
                  >>>
                  >>>Mike
                  >>>
                  >>>[/color]
                  >>
                  >>
                  >>x01 is a string containing the characters "x', '0' and '1'.
                  >>
                  >>0x01 is a one (or more) byte value with the lowest order bit on (and the
                  >>rest off).
                  >>
                  >>[/color]
                  >
                  >
                  > Also, "and" is a logical and, not a bit and. Any non-zero value will be
                  > true.
                  >
                  > If you need more help, I suggest you post all the failing code - not
                  > just a line or two.
                  >[/color]

                  I'm also confused why you're using pack() when you're already working on
                  bits.

                  What exactly are you trying to do, anyway?


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

                  Comment

                  • Mike

                    #10
                    Re: Problem with AND &amp;

                    Some else suggested that. It is in this message thread.


                    "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                    news:DrCdnQAFeb QOIXveRVn-tQ@comcast.com. ..
                    Mike wrote:[color=blue]
                    > Ah, that is why the result that I am getting. I just posted the function that I created.
                    >
                    > What is a logical AND? I thought both AND and & were. I'll have to relook at the php docs!
                    >
                    > Mike
                    >
                    >
                    > "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                    > news:O--dnZ5sQK4TJXveRV n-hg@comcast.com. ..
                    > Mike wrote:
                    >[color=green]
                    >>I made the changes in the database records and in the defines. Same thing happens. Everything
                    >>equates to a 1.
                    >>
                    >>
                    >>"Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                    >>news:y8ydnXXK i4H453jenZ2dnUV Z_sSdnZ2d@comca st.com...
                    >>Mike wrote:
                    >>
                    >>[color=darkred]
                    >>>I am having a problem getting AND to work. I have a MySQL database field defined as varbinary(8)
                    >>>with X00 in it. Then I have define statements with X01 in it.
                    >>>
                    >>>define('CERT ACCESS_MEDALS', x01);
                    >>>
                    >>>Then I run the data through a function
                    >>>
                    >>>function SecurityLevel_C heck($security_ byte, $securitylevel_ bit) {
                    >>>//AND = 1 IF BOTH are 1
                    >>>return $security_byte And $securitylevel_ bit; }
                    >>>
                    >>>if(SecurityL evel_Check($rec ordSet_cert->fields['certcode_acces s'], CERTACCESS_MEDA L) == 1) {
                    >>>
                    >>>
                    >>>No matter what the values are it always returns a 1. I've looked and looked at the docs and
                    >>>cannot
                    >>>figure out what I am doing wrong. I tried AND and & and both produce different but wrong results.
                    >>>
                    >>>PLEASE throw me a bone of a hint at what I am doing wrong.
                    >>>
                    >>>Thanks.
                    >>>
                    >>>Mike
                    >>>
                    >>>[/color]
                    >>
                    >>
                    >>x01 is a string containing the characters "x', '0' and '1'.
                    >>
                    >>0x01 is a one (or more) byte value with the lowest order bit on (and the
                    >>rest off).
                    >>
                    >>[/color]
                    >
                    >
                    > Also, "and" is a logical and, not a bit and. Any non-zero value will be
                    > true.
                    >
                    > If you need more help, I suggest you post all the failing code - not
                    > just a line or two.
                    >[/color]

                    I'm also confused why you're using pack() when you're already working on
                    bits.

                    What exactly are you trying to do, anyway?


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


                    Comment

                    • Mike

                      #11
                      Re: Problem with AND &amp;

                      Under bitwise operators it has the And & as I am using it. That is what I want.

                      Ah, I see logical. What I am doing is confusing the name of the operator and the operator itself. I
                      need to use &, NOT AND!

                      Okay.

                      With this code

                      function SecurityLevel_C heck($security_ byte, $securitylevel_ bit) {
                      //AND = 1 IF BOTH are 1
                      $binarybyte = pack("n", $security_byte) ;
                      $binarybit = pack("n", $securitylevel_ bit);
                      echo "<P>SecurityLev el_Check";
                      $binanswer = $security_byte & $securitylevel_ bit;
                      $binanswer2 = $binarybyte & $binarybit;
                      echo "<P>nonbin byte=".$securit y_byte." /bit=".$security level_bit." /nonbin result is ".$binanswe r;
                      echo "<P>bin byte=".$binaryb yte." /bit=".$binarybi t." / bin result is ".(int)$binansw er2;


                      I get this output

                      SecurityLevel_C heck

                      nonbin byte=xFE /bit=2 /nonbin result is 0

                      bin byte= /bit= /bin result is 0



                      the bin byte is unreadsable chars. HOWEVER, I should not be getting a zero result.






                      "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                      news:WPednXEAf6 sWJnvenZ2dnUVZ_ tidnZ2d@comcast .com...
                      Mike wrote:[color=blue]
                      > Ah, that is why the result that I am getting. I just posted the function that I created.
                      >
                      > What is a logical AND? I thought both AND and & were. I'll have to relook at the php docs!
                      >
                      > Mike
                      >
                      >
                      > "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                      > news:O--dnZ5sQK4TJXveRV n-hg@comcast.com. ..
                      > Mike wrote:
                      >[color=green]
                      >>I made the changes in the database records and in the defines. Same thing happens. Everything
                      >>equates to a 1.
                      >>
                      >>
                      >>"Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                      >>news:y8ydnXXK i4H453jenZ2dnUV Z_sSdnZ2d@comca st.com...
                      >>Mike wrote:
                      >>
                      >>[color=darkred]
                      >>>I am having a problem getting AND to work. I have a MySQL database field defined as varbinary(8)
                      >>>with X00 in it. Then I have define statements with X01 in it.
                      >>>
                      >>>define('CERT ACCESS_MEDALS', x01);
                      >>>
                      >>>Then I run the data through a function
                      >>>
                      >>>function SecurityLevel_C heck($security_ byte, $securitylevel_ bit) {
                      >>>//AND = 1 IF BOTH are 1
                      >>>return $security_byte And $securitylevel_ bit; }
                      >>>
                      >>>if(SecurityL evel_Check($rec ordSet_cert->fields['certcode_acces s'], CERTACCESS_MEDA L) == 1) {
                      >>>
                      >>>
                      >>>No matter what the values are it always returns a 1. I've looked and looked at the docs and
                      >>>cannot
                      >>>figure out what I am doing wrong. I tried AND and & and both produce different but wrong results.
                      >>>
                      >>>PLEASE throw me a bone of a hint at what I am doing wrong.
                      >>>
                      >>>Thanks.
                      >>>
                      >>>Mike
                      >>>
                      >>>[/color]
                      >>
                      >>
                      >>x01 is a string containing the characters "x', '0' and '1'.
                      >>
                      >>0x01 is a one (or more) byte value with the lowest order bit on (and the
                      >>rest off).
                      >>
                      >>[/color]
                      >
                      >
                      > Also, "and" is a logical and, not a bit and. Any non-zero value will be
                      > true.
                      >
                      > If you need more help, I suggest you post all the failing code - not
                      > just a line or two.
                      >[/color]

                      Look at the differences between logical operators and bit operators.

                      Logical operators deal with one value - true or false. Bit operators
                      deal with each individual bit in the variable separately.

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


                      Comment

                      • Mike

                        #12
                        Re: Problem with AND &amp;

                        I am trying to test the setting of bits, each bit representing something that can be done on the
                        website.


                        "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                        news:DrCdnQAFeb QOIXveRVn-tQ@comcast.com. ..
                        Mike wrote:[color=blue]
                        > Ah, that is why the result that I am getting. I just posted the function that I created.
                        >
                        > What is a logical AND? I thought both AND and & were. I'll have to relook at the php docs!
                        >
                        > Mike
                        >
                        >
                        > "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                        > news:O--dnZ5sQK4TJXveRV n-hg@comcast.com. ..
                        > Mike wrote:
                        >[color=green]
                        >>I made the changes in the database records and in the defines. Same thing happens. Everything
                        >>equates to a 1.
                        >>
                        >>
                        >>"Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                        >>news:y8ydnXXK i4H453jenZ2dnUV Z_sSdnZ2d@comca st.com...
                        >>Mike wrote:
                        >>
                        >>[color=darkred]
                        >>>I am having a problem getting AND to work. I have a MySQL database field defined as varbinary(8)
                        >>>with X00 in it. Then I have define statements with X01 in it.
                        >>>
                        >>>define('CERT ACCESS_MEDALS', x01);
                        >>>
                        >>>Then I run the data through a function
                        >>>
                        >>>function SecurityLevel_C heck($security_ byte, $securitylevel_ bit) {
                        >>>//AND = 1 IF BOTH are 1
                        >>>return $security_byte And $securitylevel_ bit; }
                        >>>
                        >>>if(SecurityL evel_Check($rec ordSet_cert->fields['certcode_acces s'], CERTACCESS_MEDA L) == 1) {
                        >>>
                        >>>
                        >>>No matter what the values are it always returns a 1. I've looked and looked at the docs and
                        >>>cannot
                        >>>figure out what I am doing wrong. I tried AND and & and both produce different but wrong results.
                        >>>
                        >>>PLEASE throw me a bone of a hint at what I am doing wrong.
                        >>>
                        >>>Thanks.
                        >>>
                        >>>Mike
                        >>>
                        >>>[/color]
                        >>
                        >>
                        >>x01 is a string containing the characters "x', '0' and '1'.
                        >>
                        >>0x01 is a one (or more) byte value with the lowest order bit on (and the
                        >>rest off).
                        >>
                        >>[/color]
                        >
                        >
                        > Also, "and" is a logical and, not a bit and. Any non-zero value will be
                        > true.
                        >
                        > If you need more help, I suggest you post all the failing code - not
                        > just a line or two.
                        >[/color]

                        I'm also confused why you're using pack() when you're already working on
                        bits.

                        What exactly are you trying to do, anyway?


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


                        Comment

                        • Jerry Stuckle

                          #13
                          Re: Problem with AND &amp;

                          Mike wrote:[color=blue]
                          > Some else suggested that. It is in this message thread.
                          >
                          >
                          > "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                          > news:DrCdnQAFeb QOIXveRVn-tQ@comcast.com. ..
                          > Mike wrote:
                          >[color=green]
                          >>Ah, that is why the result that I am getting. I just posted the function that I created.
                          >>
                          >>What is a logical AND? I thought both AND and & were. I'll have to relook at the php docs!
                          >>
                          >>Mike
                          >>
                          >>
                          >>"Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                          >>news:O--dnZ5sQK4TJXveRV n-hg@comcast.com. ..
                          >>Mike wrote:
                          >>
                          >>[color=darkred]
                          >>>I made the changes in the database records and in the defines. Same thing happens. Everything
                          >>>equates to a 1.
                          >>>
                          >>>
                          >>>"Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                          >>>news:y8ydnXX Ki4H453jenZ2dnU VZ_sSdnZ2d@comc ast.com...
                          >>>Mike wrote:
                          >>>
                          >>>
                          >>>
                          >>>>I am having a problem getting AND to work. I have a MySQL database field defined as varbinary(8)
                          >>>>with X00 in it. Then I have define statements with X01 in it.
                          >>>>
                          >>>>define('CER TACCESS_MEDALS' , x01);
                          >>>>
                          >>>>Then I run the data through a function
                          >>>>
                          >>>>function SecurityLevel_C heck($security_ byte, $securitylevel_ bit) {
                          >>>>//AND = 1 IF BOTH are 1
                          >>>>return $security_byte And $securitylevel_ bit; }
                          >>>>
                          >>>>if(Security Level_Check($re cordSet_cert->fields['certcode_acces s'], CERTACCESS_MEDA L) == 1) {
                          >>>>
                          >>>>
                          >>>>No matter what the values are it always returns a 1. I've looked and looked at the docs and
                          >>>>cannot
                          >>>>figure out what I am doing wrong. I tried AND and & and both produce different but wrong results.
                          >>>>
                          >>>>PLEASE throw me a bone of a hint at what I am doing wrong.
                          >>>>
                          >>>>Thanks.
                          >>>>
                          >>>>Mike
                          >>>>
                          >>>>
                          >>>
                          >>>
                          >>>x01 is a string containing the characters "x', '0' and '1'.
                          >>>
                          >>>0x01 is a one (or more) byte value with the lowest order bit on (and the
                          >>>rest off).
                          >>>
                          >>>[/color]
                          >>
                          >>
                          >>Also, "and" is a logical and, not a bit and. Any non-zero value will be
                          >>true.
                          >>
                          >>If you need more help, I suggest you post all the failing code - not
                          >>just a line or two.
                          >>[/color]
                          >
                          >
                          > I'm also confused why you're using pack() when you're already working on
                          > bits.
                          >
                          > What exactly are you trying to do, anyway?
                          >
                          >[/color]

                          Ah, I found it. No, you shouldn't need to pack your data - it's already
                          bits.

                          And please don't top post


                          A: Because it messes up the order in which people normally read text.
                          Q: Why?
                          A: Top-posting.
                          Q: What is the most annoying thing on usenet?

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

                          Comment

                          • Mike

                            #14
                            Re: Problem with AND &amp;

                            Okay, start from scratch.


                            Define code

                            define('CERTACC ESS_MEMENTRY', 0x01);


                            Function

                            function SecurityLevel_C heck($security_ byte, $securitylevel_ bit) {
                            //AND = 1 IF BOTH are 1
                            echo "<P>SecurityLev el_Check";
                            $binanswer = $security_byte & $securitylevel_ bit;
                            echo "<P>nonbin byte=".$securit y_byte." /bit=".$security level_bit." /nonbin result is ".$binanswe r;
                            return $security_byte & $securitylevel_ bit; }


                            $securitylevel_ bit is the defines like the one above. The $security_byte is the data in the database
                            record for a person.


                            Output is
                            SecurityLevel_C heck

                            nonbin byte=xFE /bit=2 /nonbin result is 0

                            SecurityLevel_C heck

                            nonbin byte=xFE /bit=1 /nonbin result is 0

                            SecurityLevel_C heck

                            nonbin byte=xFE /bit=4 /nonbin result is 0

                            SecurityLevel_C heck

                            nonbin byte=xFE /bit=8 /nonbin result is 0

                            SecurityLevel_C heck

                            nonbin byte=xFE /bit=16 /nonbin result is 0

                            SecurityLevel_C heck

                            nonbin byte=xFE /bit=32 /nonbin result is 0

                            SecurityLevel_C heck

                            nonbin byte=xFE /bit=128 /nonbin result is 0

                            SecurityLevel_C heck

                            nonbin byte=0x00 /bit=1 /nonbin result is 0

                            SecurityLevel_C heck

                            nonbin byte=0x00 /bit=2 /nonbin result is 0

                            SecurityLevel_C heck

                            nonbin byte=0x00 /bit=4 /nonbin result is 0

                            SecurityLevel_C heck

                            nonbin byte=0x00 /bit=8 /nonbin result is 0

                            SecurityLevel_C heck

                            nonbin byte=0x00 /bit=16 /nonbin result is 0






                            "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                            news:DrCdnQAFeb QOIXveRVn-tQ@comcast.com. ..
                            Mike wrote:[color=blue]
                            > Ah, that is why the result that I am getting. I just posted the function that I created.
                            >
                            > What is a logical AND? I thought both AND and & were. I'll have to relook at the php docs!
                            >
                            > Mike
                            >
                            >
                            > "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                            > news:O--dnZ5sQK4TJXveRV n-hg@comcast.com. ..
                            > Mike wrote:
                            >[color=green]
                            >>I made the changes in the database records and in the defines. Same thing happens. Everything
                            >>equates to a 1.
                            >>
                            >>
                            >>"Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                            >>news:y8ydnXXK i4H453jenZ2dnUV Z_sSdnZ2d@comca st.com...
                            >>Mike wrote:
                            >>
                            >>[color=darkred]
                            >>>I am having a problem getting AND to work. I have a MySQL database field defined as varbinary(8)
                            >>>with X00 in it. Then I have define statements with X01 in it.
                            >>>
                            >>>define('CERT ACCESS_MEDALS', x01);
                            >>>
                            >>>Then I run the data through a function
                            >>>
                            >>>function SecurityLevel_C heck($security_ byte, $securitylevel_ bit) {
                            >>>//AND = 1 IF BOTH are 1
                            >>>return $security_byte And $securitylevel_ bit; }
                            >>>
                            >>>if(SecurityL evel_Check($rec ordSet_cert->fields['certcode_acces s'], CERTACCESS_MEDA L) == 1) {
                            >>>
                            >>>
                            >>>No matter what the values are it always returns a 1. I've looked and looked at the docs and
                            >>>cannot
                            >>>figure out what I am doing wrong. I tried AND and & and both produce different but wrong results.
                            >>>
                            >>>PLEASE throw me a bone of a hint at what I am doing wrong.
                            >>>
                            >>>Thanks.
                            >>>
                            >>>Mike
                            >>>
                            >>>[/color]
                            >>
                            >>
                            >>x01 is a string containing the characters "x', '0' and '1'.
                            >>
                            >>0x01 is a one (or more) byte value with the lowest order bit on (and the
                            >>rest off).
                            >>
                            >>[/color]
                            >
                            >
                            > Also, "and" is a logical and, not a bit and. Any non-zero value will be
                            > true.
                            >
                            > If you need more help, I suggest you post all the failing code - not
                            > just a line or two.
                            >[/color]

                            I'm also confused why you're using pack() when you're already working on
                            bits.

                            What exactly are you trying to do, anyway?


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



                            Comment

                            • Mike

                              #15
                              Re: Problem with AND &amp;


                              "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                              news:RPOdnanHir JJInveRVn-gg@comcast.com. ..
                              Mike wrote:[color=blue]
                              > Some else suggested that. It is in this message thread.
                              >
                              >
                              > "Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                              > news:DrCdnQAFeb QOIXveRVn-tQ@comcast.com. ..
                              > Mike wrote:
                              >[color=green]
                              >>Ah, that is why the result that I am getting. I just posted the function that I created.
                              >>
                              >>What is a logical AND? I thought both AND and & were. I'll have to relook at the php docs!
                              >>
                              >>Mike
                              >>
                              >>
                              >>"Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                              >>news:O--dnZ5sQK4TJXveRV n-hg@comcast.com. ..
                              >>Mike wrote:
                              >>
                              >>[color=darkred]
                              >>>I made the changes in the database records and in the defines. Same thing happens. Everything
                              >>>equates to a 1.
                              >>>
                              >>>
                              >>>"Jerry Stuckle" <jstucklex@attg lobal.net> wrote in message
                              >>>news:y8ydnXX Ki4H453jenZ2dnU VZ_sSdnZ2d@comc ast.com...
                              >>>Mike wrote:
                              >>>
                              >>>
                              >>>
                              >>>>I am having a problem getting AND to work. I have a MySQL database field defined as varbinary(8)
                              >>>>with X00 in it. Then I have define statements with X01 in it.
                              >>>>
                              >>>>define('CER TACCESS_MEDALS' , x01);
                              >>>>
                              >>>>Then I run the data through a function
                              >>>>
                              >>>>function SecurityLevel_C heck($security_ byte, $securitylevel_ bit) {
                              >>>>//AND = 1 IF BOTH are 1
                              >>>>return $security_byte And $securitylevel_ bit; }
                              >>>>
                              >>>>if(Security Level_Check($re cordSet_cert->fields['certcode_acces s'], CERTACCESS_MEDA L) == 1) {
                              >>>>
                              >>>>
                              >>>>No matter what the values are it always returns a 1. I've looked and looked at the docs and
                              >>>>cannot
                              >>>>figure out what I am doing wrong. I tried AND and & and both produce different but wrong
                              >>>>results.
                              >>>>
                              >>>>PLEASE throw me a bone of a hint at what I am doing wrong.
                              >>>>
                              >>>>Thanks.
                              >>>>
                              >>>>Mike
                              >>>>
                              >>>>
                              >>>
                              >>>
                              >>>x01 is a string containing the characters "x', '0' and '1'.
                              >>>
                              >>>0x01 is a one (or more) byte value with the lowest order bit on (and the
                              >>>rest off).
                              >>>
                              >>>[/color]
                              >>
                              >>
                              >>Also, "and" is a logical and, not a bit and. Any non-zero value will be
                              >>true.
                              >>
                              >>If you need more help, I suggest you post all the failing code - not
                              >>just a line or two.
                              >>[/color]
                              >
                              >
                              > I'm also confused why you're using pack() when you're already working on
                              > bits.
                              >
                              > What exactly are you trying to do, anyway?
                              >
                              >[/color]

                              Ah, I found it. No, you shouldn't need to pack your data - it's already
                              bits.

                              And please don't top post


                              A: Because it messes up the order in which people normally read text.
                              Q: Why?
                              A: Top-posting.
                              Q: What is the most annoying thing on usenet?

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


                              Okay. Sorry.

                              Mike


                              Comment

                              Working...