I am getting an incorrect match using bitwise operators in PHP and most likely a stupid mistake but cant see the forest for the trees type scenario atm.
I have 6 permissions (1,2,4,8,16,32) and a permissions field in user login (currently set to 6)
I have simple function to return that from DB… getUserdets($LIU[‘uid’],‘Permissions’) which if I echo returns correctly ‘6’
I then have a a list of all available permissions from DB and then use this to tick the ones user has permissions to…
if (getUserdets($LIU[‘uid’],‘Permissions’) & $row[1]) { echo " checked"; }
Which correctly shows 2 & 4 ticked but also 32, if I change it to…
if (6 & $row[1]) { echo " checked"; }
Then this shows correctly with just 2 & 4 ticked.
If I had any hair left I would be pulling it out at this point, can anyone help?