Reply to Re: Problem with AND &

Your name:

Reply:


Posted by Jerry Stuckle on 02/06/06 13:56

Mike wrote:
> Okay, start from scratch.
>
>
> Define code
>
> define('CERTACCESS_MEMENTRY', 0x01);
>
>
> Function
>
> function SecurityLevel_Check($security_byte, $securitylevel_bit) {
> //AND = 1 IF BOTH are 1
> echo "<P>SecurityLevel_Check";
> $binanswer = $security_byte & $securitylevel_bit;
> echo "<P>nonbin byte=".$security_byte." /bit=".$securitylevel_bit." /nonbin result is ".$binanswer;
> 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_Check
>
> nonbin byte=xFE /bit=2 /nonbin result is 0
>
> SecurityLevel_Check
>
> nonbin byte=xFE /bit=1 /nonbin result is 0
>
> SecurityLevel_Check
>
> nonbin byte=xFE /bit=4 /nonbin result is 0
>
> SecurityLevel_Check
>
> nonbin byte=xFE /bit=8 /nonbin result is 0
>
> SecurityLevel_Check
>
> nonbin byte=xFE /bit=16 /nonbin result is 0
>
> SecurityLevel_Check
>
> nonbin byte=xFE /bit=32 /nonbin result is 0
>
> SecurityLevel_Check
>
> nonbin byte=xFE /bit=128 /nonbin result is 0
>
> SecurityLevel_Check
>
> nonbin byte=0x00 /bit=1 /nonbin result is 0
>
> SecurityLevel_Check
>
> nonbin byte=0x00 /bit=2 /nonbin result is 0
>
> SecurityLevel_Check
>
> nonbin byte=0x00 /bit=4 /nonbin result is 0
>
> SecurityLevel_Check
>
> nonbin byte=0x00 /bit=8 /nonbin result is 0
>
> SecurityLevel_Check
>
> nonbin byte=0x00 /bit=16 /nonbin result is 0
>
>
Mike,

You're getting closer - but you're still passing the STRING "xFE" as the
first parameter, not a HEX value. When converted to a number for the
bit operations, the string will be converted to zero.

You need to pass a numeric value to the function.

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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация