I have the following PHP method:
public function addIndividual($conn, $hhid,
$marital_status,
$family_relation,
$ind_id,
$ind_id,
$head_of_hh,
$ind_first_name_ar,
$ind_last_name_ar,
$ind_first_name_en,
$ind_last_name_en,
$date_added,
$gender,
$dob,
$ind_status,
$arrayOfLegalProtection,
$user_id
)
{
$res = $this->checkNumberOfIndividual($conn, $household_id);
if($res=="enableAddInd")
{
try
{
$add = "INSERT INTO individual(hhid,
family_relation_id,
marital_status_id,
ind_id, ind_id,
head_of_hh, ind_first_name_ar, ind_last_name_ar,
ind_first_name_en, ind_last_name_en,
dob, ind_status,
ind_date_added, user_id)
VALUES (:hhid,
:family_relation_id,
:marital_status_id,
:ind_id, :ind_id,
:head_of_hh, :ind_first_name_ar, :ind_last_name_ar,
:ind_first_name_en, :ind_last_name_en,
:dob, :ind_status,
:ind_date_added, :user_id);
$execAdd = $this->conn->prepare($add);
$execAdd->bindValue('hhid', $hhid);
$execAdd->bindValue('family_relation_id', $family_relation);
$execAdd->bindValue('marital_status_id', $marital_status);
$execAdd->bindValue('ind_id', $ind_id);
$execAdd->bindValue('ind_id', $ind_id);
$execAdd->bindValue('head_of_hh', $head_of_household);
$execAdd->bindValue('ind_first_name_ar', $ind_first_name_ar);
$execAdd->bindValue('ind_last_name_ar', $ind_last_name_ar);
$execAdd->bindValue('ind_first_name_en', $ind_first_name_en);
$execAdd->bindValue('ind_last_name_en', $ind_last_name_en);
$execAdd->bindValue('dob', $dob);
$execAdd->bindValue('ind_status', $ind_status);
$execAdd->bindValue('user_id', $user_id);
$execAdd->execute();
$id = $conn->lastInsertId();
$ind_action = 'HH First Time added';
//Add into HH history
$this->addHHHistory($conn, $unit_id, $id, $hh_id, $last_name_en,
$last_name_ar, $un_id, $num_ind_of_hh,
$gov_id_type, $gov_id_number, $phone_number,
$address_in_origin_country, $hh_status, $date_added,
$hh_action,
$user_id);
$arr = json_decode($arrayOfLegalProtection, true);
//Add Array of protection, situation and legals
if(sizeof($arr)>0)
{
foreach($arr as $array)
{
if($array['situationId']=='')
{
$situation_id=null;
}
else{
$situation_id = $array['situationId'];
}
if($array['legalId']==='')
{
$legal_id=null;
}
else{
$legal_id = $array['legalId'];
}
if($array['protectionId']==='')
{
$protection_id=null;
}
else{
$protection_id = $array['protectionId'];
}
if($array['willing_to_go_back']==='')
{
$willing_to_go_back='';
}
else{
$willing_to_go_back = $array['willing_to_go_back'];
}
$status = 'Active';
try
{
$sqlActualities = 'INSERT into household_protection_legal(
hhid,
unit_id,
protection_id,
legal_id,
situation_id,
willing_to_go_back, unit_household_protection_status, unit_household_protection_date_added, user_id)
VALUES(:hhid,
:unit_id,
:protection_id,
:legal_id,
:situation_id,
:willing_to_go_back,
:unit_hh_protection_status,
:unit_hh_protection_date_added,
:userId)';
$sqlActExec = $this->conn->prepare($sqlActualities);
$sqlActExec->bindValue('household_id', $id);
$sqlActExec->bindValue('unit_id', $unit_id);
$sqlActExec->bindValue('protection_id', $protection_id);
$sqlActExec->bindValue('legal_id', $legal_id);
$sqlActExec->bindValue('situation_id', $situation_id);
$sqlActExec->bindValue('willing_to_go_back', $willing_to_go_back);
$sqlActExec->bindValue('unit_household_protection_status', $status);
$sqlActExec->bindValue('unit_household_protection_date_added', $date_added);
$sqlActExec->bindValue('userId', $user_id);
$sqlActExec->execute();
//return $res;
}
catch(PDOException $e)
{
return $e->getMessage();
}
}
}
}
}
catch(PDOException $e)
{
return $e->getMessage();
}
return $id;
}
else{
return $res;
}
}
I am getting the following error on load of the component:
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in C:\wamp64\www\dev\api.php on line 1005
The line 1005 is:
if($array['situationId']=='')
I read about the problem in this documentation but I have never been able to solve my problem.
I tried to search whites spaces or even missing colons or commas, but I didn't find anything wrong.