Possible bug with PHP v4.1.1 and bits?
| From: | Daevid Vincent | Date: | Fri, 03 Jan 2003 13:54:48 +0000 |
| Subject: | Possible bug with PHP v4.1.1 and bits? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-130095@lists.php.net to get a copy of this message | ||
I'm not even sure how to classify this...
Given:
<INPUT NAME="action" TYPE="SUBMIT"
VALUE='<?=$Enabled?>');">
Where $Enabled is either a 0 or 1 as read from a database ( TINYINT(1)
);
And
echo "action = ".$_POST[action]."<BR>";
if ($_POST[action] == "1" || $_POST[action] == "0")
echo = "UPDATE Company SET Enabled = ".!(intval($_POST[action]))."
WHERE CompanyID = $id";
(skipping all the obvious bits -- no pun intended)
I cannot figure out how to simply make the 0 and 1 invert or negate or
toggle as it were.
When I submit the form, my output is:
action = 0
UPDATE Company SET Enabled = 1 WHERE CompanyID = 89
action = 1
UPDATE Company SET Enabled = WHERE CompanyID = 17
I've tried all kinds of combinations, but whenever the action is 1 to
begin with, the 'inverted' version is always blank or -2 when I would
expect it to be 0.
If I use
echo = "UPDATE Company SET Enabled = ".~(intval($_POST[action]))."
WHERE CompanyID = $id";
action = 1
UPDATE Company SET Enabled = -2 WHERE CompanyID = 17