473,624 Members | 2,584 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
Feb 5 '06 #1
21 1787
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('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


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

http://us2.php.net/manual/en/function.pack.php
http://us2.php.net/manual/en/function.unpack.php

M.
Feb 5 '06 #2
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('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


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.
js*******@attgl obal.net
=============== ===
Feb 5 '06 #3
I made the changes in the database records and in the defines. Same thing happens. Everything
equates to a 1.
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
news:y8******** *************** *******@comcast .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('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


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.
js*******@attgl obal.net
=============== ===
Feb 6 '06 #4
Mike wrote:
I made the changes in the database records and in the defines. Same thing happens. Everything
equates to a 1.
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
news:y8******** *************** *******@comcast .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('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

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).


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.
js*******@attgl obal.net
=============== ===
Feb 6 '06 #5
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" <no***@nowhere. com> wrote in message news:gy******** *********@newss vr25.news.prodi gy.net...
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('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


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

http://us2.php.net/manual/en/function.pack.php
http://us2.php.net/manual/en/function.unpack.php

M.


Feb 6 '06 #6
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" <js*******@attg lobal.net> wrote in message
news:O-*************** *****@comcast.c om...
Mike wrote:
I made the changes in the database records and in the defines. Same thing happens. Everything
equates to a 1.
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
news:y8******** *************** *******@comcast .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('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

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).


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.
js*******@attgl obal.net
=============== ===
Feb 6 '06 #7
Mike wrote:
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" <js*******@attg lobal.net> wrote in message
news:O-*************** *****@comcast.c om...
Mike wrote:
I made the changes in the database records and in the defines. Same thing happens. Everything
equates to a 1.
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
news:y8****** *************** *********@comca st.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('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

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).

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.


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.
js*******@attgl obal.net
=============== ===
Feb 6 '06 #8
Mike wrote:
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" <js*******@attg lobal.net> wrote in message
news:O-*************** *****@comcast.c om...
Mike wrote:
I made the changes in the database records and in the defines. Same thing happens. Everything
equates to a 1.
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
news:y8****** *************** *********@comca st.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('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

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).

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.


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.
js*******@attgl obal.net
=============== ===
Feb 6 '06 #9
Some else suggested that. It is in this message thread.
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
news:Dr******** ************@co mcast.com...
Mike wrote:
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" <js*******@attg lobal.net> wrote in message
news:O-*************** *****@comcast.c om...
Mike wrote:
I made the changes in the database records and in the defines. Same thing happens. Everything
equates to a 1.
"Jerry Stuckle" <js*******@attg lobal.net> wrote in message
news:y8****** *************** *********@comca st.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('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

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).

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.


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.
js*******@attgl obal.net
=============== ===
Feb 6 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
3216
by: johkar | last post by:
When the output method is set to xml, even though I have CDATA around my JavaScript, the operaters of && and < are converted to XML character entities which causes errors in my JavaScript. I know that I could externalize my JavaScript, but that will not be practical throughout this application. Is there any way to get around this issue? Xalan processor. Stripped down stylesheet below along with XHTML output. <?xml version='1.0'?>...
2
5277
by: chris | last post by:
Hi there, I create an XML file from a dataset like this: System.IO.StreamWriter xmlSW = new System.IO.StreamWriter(FILENAME); dsUserData1.WriteXml(xmlSW, XmlWriteMode.WriteSchema); xmlSW.Close(); Which gives me this XML file: <NewDataSet>
5
2592
by: comshiva | last post by:
Hi all, I have converted my existing ASP.NET project from 1.1 to 2.0 and i have found that everything works fine except the linkbutton control in my datagrid which throws an javascript error when clicked. I thought the control might be the problem, so i deleted the old control and binded the new linkbutton control but am still getting the same error. Am using visual studio 2005. Source code inside my grid:...
16
4901
by: Dany | last post by:
Our web service was working fine until we installed .net Framework 1.1 service pack 1. Uninstalling SP1 is not an option because our largest customer says service packs marked as "critical" by Microsoft must be installed on their servers. Now german Umlaute (ä, ü, ö) and quotes are returned incorrectly in SOAP fault responses. This can be easily verified: Implement the following in a web service method (just raises a SOAPException with a...
1
1482
by: Joe | last post by:
I want to save some URLs into a XML formatted document. > > I find out that its having some problems due to some of the characters > used > in the URL. > > Is there a quick way to get around that? Thanks. > > Here are some of the URL characters in the parameters >
6
4076
by: comp.lang.php | last post by:
I am trying to pipe in some auto-generated PHP into php.exe, to no avail: catch {exec echo '<? if (@is_file("./functions.inc.php")) { require_once("./functions.inc.php"); echo xml_to_tcl_list("&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;&lt;fortune&gt;&lt;saying id=&quot;1&quot; author=&quot;Phil Powell&quot; phrase=&quot;New York is SO Superior!&quot;&gt;&lt;/saying&gt;&lt;saying id=&quot;2&quot; author=&quot;Phil Powell&quot;...
3
4454
by: gg | last post by:
I specify the Url element as <xsd:element name="Url"> <xsd:simpleType> <xsd:restriction base="xsd:string"> <xsd:maxLength value="512"/> <xsd:pattern value="http://+"/> </xsd:restriction> </xsd:simpleType> </xsd:element> in the xsd but When I use the following in the xml
3
5379
polymorphic
by: polymorphic | last post by:
I have succeeded in embedding PDF files in a dynamic iframe. The problem is that I need the PDF to cache. If the PDF remains the same from page load to page load then the pdf is somehow cached with the html page. But if I try to navigate to another pdf in the IFRAME then no caching occurs. Is the problem in the IFRAME reloading instead of just refreshing the pdf? <SCRIPT type="text/javascript"> var pageNo; var nav; var iframe; var...
5
1666
by: Juan R. =?iso-8859-1?q?Gonz=E1lez-=C1lvarez?= | last post by:
I want to substitute "\(" by "(" i have tried content = content.replace(/\\\(/g, "("); content = content.replace(/\\\(/g, unescape("%26") + "#40;"); content = content.replace(/\\\(/g, "\&" + "#40;");
2
2633
by: bvdamme | last post by:
Hello, In my httpd error_log file I get following error : PHP Warning: include(http://filuntu/php/includes/header.php? mask_menu1=1111&amp;mask_menu2=111111&amp;terug=/php/hoofdmenu.php) : failed to open stream: HTTP request failed! HTTP/1.1 401 Authorization Required\r\n in /mnt/vg_hdg_3/alegra/website/php/hoofdmenu.php on line 43
0
8249
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8179
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8685
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8493
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7176
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6112
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4187
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1797
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.