Jump to content

Archived

This topic is now archived and is closed to further replies.

Silus

Automatic timestamp

Recommended Posts

I'm really new to mysql, but I would like to add a timestamp to a row when it is added automatically.

Thanks.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
You should probably use a column list for your INSERT statements.

Share this post


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

Share this post


Link to post
Share on other sites
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 em

insert into stats (cola,colb) values($input3,$input4);

It made it much easier to see what was exactly causing the error.

Thanks for the help

Share this post


Link to post
Share on other sites
Glad you got it working... I always thought that have no column list should be a syntax error.

Share this post


Link to post
Share on other sites

×

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.