Jump to content

update timestamp not working and affecting other field


pcw

Recommended Posts

Hi, the code below updates the online field with yes when a user logs in. I also wanted to add the current timestamp to the database eachtime the user logs in.

 

This works fine for updating the online field with yes

 

mysql_query("UPDATE members SET online = 'yes' 
WHERE username = '$username'");

 

However when I put it like this, so it updates the timestamp, the logindate field in the database is not updated and a 0 gets placed in the online field? Im really confused at this lol

 

mysql_query("UPDATE members SET online = 'yes' AND logindate = 'CURRENT_TIMESTAMP'
WHERE username = '$username'");

 

Again, any help is much appreciated

 

Paul

Shouldn't be any quotes around the MySQL CURRENT_TIMESTAMP() function . . .

"UPDATE members SET online = 'yes' AND logindate = CURRENT_TIMESTAMP() WHERE username = '$username'"

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.