'" . time() . "' you're passing that as a string literal, it's a function.
UPDATE user SET user_onlineStatus = time() WHERE user_id='" . $user_id . "'
However, time() returns as a Unix timestamp 1463338870 format, rather than 2016-05-15 19:01:39 which is why it's failing you here, seeing your user_onlineStatus column is a TIMESTAMP type.
Ideally, you would be better off using the "now" method of today's time and date, your column type should either be DATE or DATETIME. Sidenote: As noted, a TIMESTAMP type is also valid (as per RiggsFolly's comment below).
so
"UPDATE user SET user_onlineStatus = now() WHERE user_id='$user_id' ";
If it isn't either, then I suspect it to be VARCHAR which is a bad idea.
Reference on DATE, DATETIME, and TIMESTAMP Types
If none of those worked for you, then your $user_id may be failing and is unknown whether or not it contains a value.
Make sure it does have a value, so check for errors.
Consult these following links http://php.net/manual/en/mysqli.error.php and http://php.net/manual/en/function.error-reporting.php
and apply that to your code.
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$setLogged = mysqli_query($conn,
"UPDATE user SET user_onlineStatus = NOW()
WHERE user_id='" . $user_id . "' ") or die(mysqli_error($conn));
A few unknowns:
- If you're using sessions. If so, make sure you started the session.
- The MySQL API to connect with. If you're using anything other than
mysqli_ to connect with, those different APIs do not intermix.
Foonotes:
Your present code is open to SQL injection. Use prepared statements, or PDO with prepared statements.