I have this code snippet
$taskAssignedCompleteId = $row["TaskAssignCompletionId"];
echo "taskAssignedCompleteId::".$taskAssignedCompleteId. "
";
if($taskAssignedCompleteId == 0 || $taskAssignedCompleteId = null)
{
echo "Currently no task assigned to you. If you are not doing a task on PMS and still receving this massage then, contact your team lead";
return;
}
$sqlInsert = "INSERT INTO emp_task_finished_request (EmpTaskAssignCompletionId, RequestDateTime) VALUES (".$taskAssignedCompleteId.", '$date')";
echo "output : ".$sqlInsert;
$queryInsert = $connPDO->exec($sqlInsert);
echo "
output : ".$queryInsert;
Surprisingly $taskAssignedCompleteId
value is not showing in query when i echo my $queryInsert
varaiable while it is perfectly showing when i directly echo $taskAssignedCompleteId
. Why is the problem? it is very strange for me. here is my output
taskAssignedCompleteId::13
sqlInsert full : INSERT INTO emp_task_finished_request (EmpTaskAssignCompletionId, RequestDateTime) VALUES (, '2017-07-05 16:53:45')
output :
You need to correct your if statement. $taskAssignedCompleteId = null
is not correct. Kindly replace it by following
if($taskAssignedCompleteId == 0 || $taskAssignedCompleteId == null)
you should use ==
for comparison
operator . =
is assignment
operator .so it's assigning null
to $taskAssignedCompleteId
variable .
if($taskAssignedCompleteId == 0 || $taskAssignedCompleteId == null) { .. }
Change $taskAssignedCompleteId = null
to $taskAssignedCompleteId == null
By doing this, you are assigning taskAssignedCompleteId
to a null value. To compare use "==" but you already know that. Just a typo I guess.
Darn, somebody beat me to the answer as I'm typing this.