Jump to content

Update Timestamp - Solved With Our Thanks In The Final Post.


niche

Recommended Posts

How do I get the the timestamp in to the expire_ts column? This query doesn't produce any errors, but fails to update with the timestamp. echo $expire_ts says "2011-09-09 14:41:15". The expire_ts is formated as "timestamp" Code:

$expire_ts = date('Y-m-d H:i:s',$expire);   mysql_query("UPDATE cookie SET timestamp = TIMESTAMP(NOW()), period_in_sec = '.$expire.', expire_ts = TIMESTAMP(' . $expire_ts . ') WHERE id = " . $id) or die(mysql_error());  

Link to comment
Share on other sites

I changed this -expire_ts = TIMESTAMP(' . $expire_ts . ')to this -expire_ts = TIMESTAMP(' $expire_ts ')and I got the desired results, but how can that be? Why no concatenate in this situation?

Link to comment
Share on other sites

You're mixing up single and double quotes. The query string is surrounded by double quotes, not single quotes. The field value should be surrounded by single quotes, so that's why it works. The original wasn't concatenating, it was putting the dots before and after the value in the query.

Link to comment
Share on other sites

You're right. I was mixed-up. I just didn't know why. Thanks for the redirection justsomeguy.

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...