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
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]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.