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) Link to comment https://forums.phpfreaks.com/topic/35007-phpmyadmin-and-timestamps/ 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. Link to comment https://forums.phpfreaks.com/topic/35007-phpmyadmin-and-timestamps/#findComment-165121 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. Link to comment https://forums.phpfreaks.com/topic/35007-phpmyadmin-and-timestamps/#findComment-165124 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 Link to comment https://forums.phpfreaks.com/topic/35007-phpmyadmin-and-timestamps/#findComment-165127 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] Link to comment https://forums.phpfreaks.com/topic/35007-phpmyadmin-and-timestamps/#findComment-165219 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.