0

I have this code snippet

$taskAssignedCompleteId = $row["TaskAssignCompletionId"];
echo "taskAssignedCompleteId::".$taskAssignedCompleteId. "\n";

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 "\n 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 :
Dileep Kumar
  • 1,077
  • 9
  • 14
Muhammad Faizan Khan
  • 10,013
  • 18
  • 97
  • 186

3 Answers3

1

You need to correct your if statement. $taskAssignedCompleteId = null is not correct. Kindly replace it by following

if($taskAssignedCompleteId == 0 || $taskAssignedCompleteId == null)
Ayaz Ali Shah
  • 3,453
  • 9
  • 36
  • 68
0

you should use == for comparison operator . = is assignment operator .so it's assigning null to $taskAssignedCompleteId variable .

if($taskAssignedCompleteId == 0 || $taskAssignedCompleteId == null) { .. }
JYoThI
  • 11,977
  • 1
  • 11
  • 26
0

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.

Joey Ezekiel
  • 1,017
  • 1
  • 11
  • 26