Jump to content

phpMyAdmin and timestamps


AdRock

Recommended Posts

I need some help with setting up my tables

I have a form where I enter some information about my articles and when i save them it inserts the current timestamp into time field of my database usinbg this insert statement

[code]$query = "INSERT INTO articles VALUES ('','$name','$message',now(),'$pic')";[/code]

When i update a record I don't want to update the time field with the current timestamp

[code]$query="UPDATE articles SET title='$name', content='$message' WHERE id='$ud_id'";[/code]

whenever I update a record the time field is updating with the current timestamp which i don't want it to.

How do i set up the time field so it doesn't update the current timestamp unless i tell it to using a SQL query?

Field info

Type - TIMESTAMP
Attributes - ON UPDATE CURRENT TIMESTAMP
Null - NOT NULL
Default[sup]2[/sup] - CURRENT TIMESTAMP (ticked box)

Link to comment
https://forums.phpfreaks.com/topic/35007-phpmyadmin-and-timestamps/
Share on other sites

Set the type to INT(11) and whenever you run a query you'll need to do it like...

[code=php:0]$query = "INSERT INTO articles VALUES ('','$name','$message',UNIX_TIMESTAMP(),'$pic')";[/code]

or

[code=php:0]$query="UPDATE articles SET time=UNIX_TIMESTAMP() WHERE id='$ud_id'";[/code]

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.