twilitegxa Posted August 20, 2008 Share Posted August 20, 2008 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. Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted August 20, 2008 Share Posted August 20, 2008 you can always add it to your insert query and for the value set it to NOW() Quote Link to comment Share on other sites More sharing options...
peddel Posted August 20, 2008 Share Posted August 20, 2008 Im using wampserver for testing also. I always divide my timestamps into seperate variables. Then with the INSERT command i just inser those variables in different collums. Dont know if this can help ya out ??? Quote Link to comment Share on other sites More sharing options...
Mchl Posted August 20, 2008 Share Posted August 20, 2008 You need to set it up to DEFAULT CURRENT_TIMESTAMP and insert NULL into it. See: http://dev.mysql.com/doc/refman/5.0/en/timestamp.html Quote Link to comment Share on other sites More sharing options...
fenway Posted August 20, 2008 Share Posted August 20, 2008 Can we see the insert query? Is it the first TIMESTAMP column? Quote Link to comment Share on other sites More sharing options...
twilitegxa Posted August 20, 2008 Author Share Posted August 20, 2008 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 :-\ Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted August 20, 2008 Share Posted August 20, 2008 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 Quote Link to comment Share on other sites More sharing options...
twilitegxa Posted August 20, 2008 Author Share Posted August 20, 2008 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. Quote Link to comment Share on other sites More sharing options...
Mchl Posted August 20, 2008 Share Posted August 20, 2008 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. Quote Link to comment Share on other sites More sharing options...
twilitegxa Posted August 20, 2008 Author Share Posted August 20, 2008 Got it figured out, thanks! 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.