Silus Posted August 4, 2006 Share Posted August 4, 2006 I'm really new to mysql, but I would like to add a timestamp to a row when it is added automatically.Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/16515-automatic-timestamp/ Share on other sites More sharing options...
Silus Posted August 4, 2006 Author Share Posted August 4, 2006 I figured it out.I had to [b]alter table stats add timestamp timestamp;[/b]then when I added data from a script I put null into the timestamp field[b]echo "insert into stats values ( $input4 , $input5 , $input6 , $input13 , $input14 , $input15 , $input16,null );"[/b]the $input#'s are just some script variables I added to the table. Quote Link to comment https://forums.phpfreaks.com/topic/16515-automatic-timestamp/#findComment-69002 Share on other sites More sharing options...
fenway Posted August 4, 2006 Share Posted August 4, 2006 You should probably use a column list for your INSERT statements. Quote Link to comment https://forums.phpfreaks.com/topic/16515-automatic-timestamp/#findComment-69202 Share on other sites More sharing options...
Silus Posted August 4, 2006 Author Share Posted August 4, 2006 Probably so as it stopped working for no apparent reason.BTW can you give an example of a column list and why is it preferrable?Thanks Quote Link to comment https://forums.phpfreaks.com/topic/16515-automatic-timestamp/#findComment-69302 Share on other sites More sharing options...
Silus Posted August 4, 2006 Author Share Posted August 4, 2006 I see that it broke actually because a scipt was returning data differently than previously(I don't know why this is the case).Anyways, I swapped to the column list where I list the column names then the data that goes in eminsert into stats (cola,colb) values($input3,$input4);It made it much easier to see what was exactly causing the error.Thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/16515-automatic-timestamp/#findComment-69323 Share on other sites More sharing options...
fenway Posted August 4, 2006 Share Posted August 4, 2006 Glad you got it working... I always thought that have no column list should be a syntax error. Quote Link to comment https://forums.phpfreaks.com/topic/16515-automatic-timestamp/#findComment-69448 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.