AdRock Posted January 20, 2007 Share Posted January 20, 2007 I need some help with setting up my tablesI 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 infoType - TIMESTAMPAttributes - ON UPDATE CURRENT TIMESTAMPNull - NOT NULLDefault[sup]2[/sup] - CURRENT TIMESTAMP (ticked box) Quote Link to comment Share on other sites More sharing options...
metrostars Posted January 20, 2007 Share Posted January 20, 2007 Try unticking the last default box.Don't know if it'll work but it's worth a try. Quote Link to comment Share on other sites More sharing options...
ShogunWarrior Posted January 20, 2007 Share Posted January 20, 2007 Set the type of the column to INT UNSIGNED instead of timestamp. You get the same input/output but know you can control the field. Quote Link to comment Share on other sites More sharing options...
AdRock Posted January 20, 2007 Author Share Posted January 20, 2007 That didn't work....by setting the type top integer I only got 2007 instead of the full date Quote Link to comment Share on other sites More sharing options...
Nhoj Posted January 21, 2007 Share Posted January 21, 2007 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] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.