I am getting the above error in the last line of code ,I have tried answers but that doesnt seems to work
if (isset($_GET['logout'])) {
$name = $_SESSION["username"];
date_default_timezone_set('Asia/Kolkata');
$today = date('Y-m-d');
$time = new DateTime(date('H:i:s'));
$statement = $db->prepare("SELECT `logintime` FROM `attendance` WHERE empid=? AND date_t=?");
$statement->bind_param("ss", $name, $today);
$statement->execute();
$statement->bind_result($logintime);
while ($statement->fetch()) {
}
$logintime = new DateTime($logintime);
$interval = $logintime->diff($time);
$hours = $interval->format('%h');
$minutes = $interval->format('%i');
$workinghours = $hours + $minutes / 60;
$stmt = $db->prepare("UPDATE `attendance` SET `logouttime`=? ,`workinghours`=? WHERE empid=? AND date_t=?");
$stmt->bind_param("ssss", $time, $workinghours, $name, $today);
$run = $stmt->execute();
}