Sir, my table look like this


I am using this query to insert data

         $query = "INSERT INTO history(user, login, logout, duration, user_ip, user_lo)
          VALUES ('".$muser."','".($date('Y-m-d H:i:s')."','".($date('Y-m-d H:i:s')."',1,'".$_SERVER['SERVER_ADDR']."','myplace')";

But it says:
Parse error: syntax error, unexpected ';' in C:\wamp\www......

I am unable to know what is wrong in my query, please help


look I will not fix that query as it would be wrong in any case. Use prepared statements.

Example with PDO:

$query = "INSERT INTO `history` (`user`, `login`, `logout`, `duration`, `user_ip`, `user_lo`) VALUES (:user, :date, :date, 1, :ip, 'myplace')";

Then use bindParam():

$stmt = $conn->prepare($query);
$stmt->bindParam(':user', $muser);
$stmt->bindParam(':ip', $_SERVER['REMOTE_ADDR']);
$stmt->bindParam(':date', date('Y-m-d H:i:s'));

if($stmt->execute() === TRUE) echo 'success';
else echo 'fail';

Instead of the :date placeholder, if you're using MySQL, you could simply use the NOW() function. Docs: