0

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?

Ejaz
  • 8,719
  • 3
  • 34
  • 49

1 Answers1

0

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

Community
  • 1
  • 1
DarkSide
  • 3,670
  • 1
  • 26
  • 34
  • man...everybody say timestamp is the best so i put it didnt,know this is part of it, anyway, tnx! – user2061082 May 07 '14 at 13:15
  • Timestamp is useful in some cases, but to really use it you first need to understand every aspect of it in MySQL DB. Simplest usage is for `last_time_updated` type of fields, but timestamp can be used in other cases too. Note, that it's hard (MySQL issues) to use more than one timestamp field in table. – DarkSide May 07 '14 at 22:18