I have the following code, I seem to be having problems with booleans in php, when ever i dump out the value of bCreatedEvent it is just empty, what am i doing wrong and I’m using booleans wrong? It also fails my logic check so i can redirect at the bottom. I’m fairly new to php, but thought most of this should work similar to 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 be the same length
{
for ($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))
{
for ($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
falsewill look empty usevar_dump($bEventCreated)Also
&is a bitwise operator I think you mean&&