Jump to content

[SOLVED] TIMESTAMP won't generate a date and time in database


twilitegxa

Recommended Posts

I have a field set to TIMESTAMP in my table and have it set to ON UPDATE CURRENT_TIMESTAMP for the attribute and CURRENT_TIMESTAMP for the default, but everytime I submit the form (it's a guestbook form), I want it to automatically enter inot my database what time the post was submitted, but right now all it is submitting is zeros. Can anyone tell me what I'm doing wrong? I'm using a bundled program named WampServer, if anyone's familiar.

I haven't used a query yet. I just set it up in this program that auomatically does it for you. Might be better to use a query at this point  :-\

 

So you don't know how to write any mysql queries?

 

we can't help you very much than

I know how to write some queries, but I am new to MySQL, so I'm a little unsure about some of the queries. I don't quite understand the timestamp one.

 

I am using WampServer, like I said, and it lets you name your table and then add the fields to the table with the different parts like the type and stuff like that. I have it set to timestamp, and I have ON UPDATE CURRENT_TIMESTAMP and CURRENT_TIMESTAMP set, but when I enter a record with my form, it saves a blank or all zeros date and time. I can't figure out what I'm doing wrong. Do I need to have the form send the timestamp to my database? Or will it automatically do that when a recrd is submitted? Because right now I just have the other fields that the user fills in.

Let's take it step by step.

 

Go to phpMyAdmin, select a database and create new table with three fields

 

Call the first field ID, set its type to INT(10), select attributes to 'UNSIGNED', don't set default value, set additional as auto_increment, and select radiobutton under the icon with key (primary key)

 

Call the second one TS, set it type to TIMESTAMP, now in the 'default' column a checkbox should appear with CURRENT_TIMESTAMP next to it. Check it.

 

Call the third field 'value', set it to VARCHAR(20)

 

 

After creating this table, add new row to it. Don;t enter anything into ID nor TS, just enter value.

Archived

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

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