I have this weird situation where my query isn't doing what it's supposed to do.
Here is my not working code:
$aanbodID = 1;
$db = //connection
$getData = $db->query("SELECT boekbaar_iframe FROM aanbod_20160206 WHERE id_aanbod=$aanbodID") or die(mysql_error());
while ($row_content = mysql_fetch_array($getData))
{
$zichtbaarjanee = $row_content['boekbaar_iframe']; // 0 or 1
}
if ($zichtbaarjanee == 0)
{
$nieuwewaarde = 1;
}else{
$nieuwewaarde = 0;
}
db->query("UPDATE aanbod_20160206 SET boekbaar_iframe = '$nieuwewaarde' WHERE id_aanbod = '$aanbodID'");
echo mysql_error();
And here is almost the same code that is working:
$aanbodID = 1;
$db = //connection
$getData = $db->query("SELECT boekbaar_iframe FROM aanbod_20160206 WHERE id_aanbod=$aanbodID") or die(mysql_error());
while ($row_content = mysql_fetch_array($getData))
{
$zichtbaarjanee = $row_content['boekbaar_iframe']; // 0 or 1
}
//switch these vars and its working
$nieuwewaarde = 0;
// $nieuwewaarde = 1;
db->query("UPDATE aanbod_20160206 SET boekbaar_iframe = '$nieuwewaarde' WHERE id_aanbod = '$aanbodID'");
echo mysql_error();
So i'm guessing the problem is somewhere in the if statement, but i've tried everything, also with and without ' ' or " ".
update: changed querys to mysqli_*
the problem is still in the if/else statement
because this is working:
//if ($zichtbaarjanee == 0)
//{
// $nieuwewaarde = 1;
//}else{
$nieuwewaarde = 0;
//}
When I switch the 0 for a 1 it's also working, but when i comment in the piece of code it stops updating the table
Please help!