JTsToolbox JTsToolbox - 2 months ago 10
MySQL Question

UPDATE query updates all TIMEDATE columns previously set with now

I am working on a membership script, and can't for the life of me figure out whats wrong with my query... anyone have any idea's? Think I need a second set of eyes.. Originally I was just sending

$sqlquery2 = "UPDATE users SET lastvisit = now() WHERE id = '" . $id ."'";

but it was updating the joined_date column as well. So I tried this and broke it further.


//These variables are pulled from prior query

$id = $row['id'];
$hashed_password = $row['password'];
$username = $row['username'];
$joined = $row['join_date'];
$salt = $row['salt'];
$email = $row['email'];

//compare password pulled from database
$sqlquery2 = "UPDATE users SET lastvisit = now(), join_date = ".$joined." WHERE id = '" . $id ."'";

//$joined is equal to 2016-10-19 17:24:08


Please check whether your joined_date is a TIMESTAMP column. If so following will help you. http://dev.mysql.com/doc/refman/5.7/en/timestamp-initialization.html