I have this php file for store the logout time. Using insert query I store the login time first. Then I store the logout time using this logout script. The error I'm getting is the one I mentioned in my code which is `failed to insert logout time`. the `$lgotime` and `$lrec` are echoing correctly. Below is my code:

```
<?php

session_start();

$lgotime = date("Y-m-d H:i:s");

$lrec = $_SESSION['lreclast'];

echo $lgotime;

echo "</br>";

echo $lrec;

mysql_query("UPDATE tbl_login_record SET logoff_time='$lgotime' WHERE id = '$lrec'") or die("failed to insert logout time");

session_destroy();
header("Location:../login.php");
?>

```

the `$lrec` variable is coming from `mysql_insert_id()` from the script that has the insert query. Help will be really appreciated.