I have the following PHP script that I am trying to execute. Its very simple yet I am overlooking something since it is not working correctly. If a user toggles a radio button, this script is called and the page is refreshed. However, the "enabled" column in MySQL never updates going from "0" to "1". If I manually enter the value of the enabled column to "1" then the script executes updating the value of the enabled column back to "0" but never to "1" again. What am I overlooking?
$sql="SELECT enabled FROM somecolumn.persist";
$row = mysql_fetch_row($sql);
$enabled=$row[0];
if ($enabled==0) {
$query="UPDATE `somecolumn`.`persist` SET `enabled` = '1' WHERE `persist`.`enabled` =0";
} else {
$query="UPDATE `somecolumn`.`persist` SET `enabled` = '0' WHERE `persist`.`enabled` =1";
}
mysql_query($query);