logic - Php Booleans not working correctly? -


i have following code, seem having problems booleans in php, when ever dump out value of bcreatedevent empty, doing wrong , i'm using booleans wrong? fails logic check can redirect @ bottom. i'm new php, thought of should work similar c/c++.

$dbtheatrecms = new theatrecmsdb();                 $ieventid = $dbtheatrecms->insertnewevent($stitle, $scompany, $icreateid, $snotes, $spreprice, $sregprice);                  $beventcreated = false;                 echo "beventcreated1 = " . $beventcreated . "<br/>";                 $beventinfoinserted = true;                 $beventrolesinserted = true;                  if ($ieventid > 0)                 {                     $beventcreated = true;                     if (isset($_post["venues"], $_post["eventdates"]))                     {                         $aivenueids = $_post["venues"];                         $adtevents = $_post["eventdates"];                         if (count($adtevents) == count($aivenueids)) // these should same length                         {                             ($i = 0; $i < count($adtevents); $i++)                             {                                 $beventinfoinserted &= ($dbtheatrecms->insertneweventinfo($ieventid, $aivenueids[$i],$adtevents[$i]) > 0) ? true :false;                             }                         }                     }                      if (isset($_post["troupers"], $_post["roles"]))                     {                         $trouperids = $_post["troupers"];                         $roles = $_post["roles"];                         if (count($trouperids) == count($roles))                         {                             ($i = 0; $i < count($trouperids); $i++)                             {                                 $beventinfoinserted &=  ($dbtheatrecms->insertnewtroupeinfo($ieventid, $trouperids[$i],$roles[$i]) > 0)? true:false;                             }                         }                     }                 }                  echo "beventcreated = " . $beventcreated . "<br/>";                 echo "beventinfoinserted = " . $beventinfoinserted . "<br/>";                 echo "beventrolesinserted = " . $beventrolesinserted . "<br/>";                  $beventcreated = $beventcreated & $beventinfoinserted & $beventrolesinserted;                 echo "$beventcreated = " . $beventcreated . "<br/>";                  if($beventcreated == true)                 {                     echo "<script type='text/javascript'>window.localstorage.href = 'some page.php';</script>";                 } 

output

beventcreated1 =  beventcreated =  beventinfoinserted = 1 beventrolesinserted = 1 0 = 0 

echo false empty use var_dump($beventcreated)

also & bitwise operator think mean &&

$beventcreated = $beventcreated & $beventinfoinserted & $beventrolesinserted; 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -