OK, it seems as though I was on the right track. I cast the variables as integers and all is well. Thanks to Rasmus and his msg: http://www.phpbuilder.com/mail/php-developer-list/199901/0485.php
A question remains: why are variables that are initially set to numbers not cast as integers? According to the manual variables are initially cast as integers if they are created with an assignment to an integer number. While this is the case with variables assigned in code (i.e. $One = 16) it appears not to be the case with GET variables passed via the URL. It may appear that GET variables passed via the URL are cast as integers if you do simple arithmatic or comparison, however it seems to me that they are cast as integers because of the context of the math or comparison operators. The bitwise operators, on the other hand, do not seem to cast the GET variables as integers and require that they be cast before the expected result can be had. I am not sure if this was intentional, but it certainly is confusing. I think a blurb in the manual would be very helpful. Fred Fred <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > I have 17 boolean variables which need to be stored in a MySQL database. I > created a SET Column to store each of the boolean values as bits in the > column. I should be able to test for the truth of a particular variable by > checking if the corresponding bit is set. > > For example, if the first four variables are set (i.e. Column = a,b,c,d) > then the numeric value of the column is 15 or 1111. To test for c I would > check to see if the third bit (4 or 100) is set. > > I chose to do the check this way: > > if ($One & $Two == $One) echo "True"; > > This does not seem to work in many instances. Take the example above: > 4 and 15 should equal 4 > 0100 and > 1111 equals > 0100 > > For some reason, my script gives 0000 as the result of 0100 and 1111. It is > fairly clear that this is not the correct behavior of the bitwise & > operator. > > Oddly enough, in some instances is works as expected: > 16 and 17 should equal 16 > 10000 and > 10001 equals > 10000 > > My script has no problem generating the expected result here. > > Perhaps this problem arises from the loosely typed nature of PHP variables, > but I do not see how it could. Any pointers would be appreciated. > > Fred > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]