Re[2]: [PHP] Possible bug with PHP v4.1.1 and bits?
| From: | Tom Rogers | Date: | Fri, 03 Jan 2003 18:22:34 +0000 |
| Subject: | Re[2]: [PHP] Possible bug with PHP v4.1.1 and bits? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-130140@lists.php.net to get a copy of this message | ||
Hi,
Saturday, January 4, 2003, 3:23:37 AM, you wrote:
FML> -----Original Message-----
FML> From: Daevid Vincent
FML> To: php-general@lists.php.net
FML> echo "action = ".$_POST[action]."<BR>";
FML> if ($_POST[action] == "1" || $_POST[action] == "0")
FML> echo = "UPDATE Company SET Enabled = ".!(intval($_POST[action]))."
FML> WHERE CompanyID = $id";
FML> I cannot figure out how to simply make the 0 and 1 invert or negate or
FML> toggle as it were.
FML> --------------------------
FML> echo = "UPDATE Company SET Enabled = ".(1-$_POST[action]) ...
FML> Cheers!
FML> Mike
In mysql you can use the invert (tilde)operator like this:
select 5 & ~1 returns 4 so you could do
"UPDATE Company SET Enabled = (Enabled & ~1)" which will toggle bit 1 of
Enabled.
(Untested :)
--
regards,
Tom