Date, time resets every time i use UPDATE,

page1

mysql_query("INSERT INTO table (time) VALUES(CURRENT_TIMESTAMP()) ") or die(mysql_error());

page2 (not connected with page1)

echo $row['time'];

and after i use

$query = mysql_query("UPDATE tablica SET views = views+1 WHERE id = '".$id."' ");

date and time resets to current date and time and if i delete UPDATE code everything is fine, type is timestamp, how to stop reseting date and time?

有帮助吗?

解决方案

If table field is defined as timestamp, then it'll update automatically when record is changed / updated.

Read more about timestamps and issues here:

http://dev.mysql.com/doc/refman/5.1/en/timestamp-initialization.html

MySQL CURRENT_TIMESTAMP on create and on update

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top