mysql date field
Moderator: General Moderators
- cbcampbell
- Forum Newbie
- Posts: 19
- Joined: Mon Jun 09, 2003 12:12 am
mysql date field
i am trying to get a date, or timestamp field in mysql to automatically insert the current date of the time i create the record. However, everytime I create a new record, it sets the date and/or timestamp field to 0's all the way across. How do I fix this problem, or is it fixable?
- cbcampbell
- Forum Newbie
- Posts: 19
- Joined: Mon Jun 09, 2003 12:12 am
Actually, I am using this with php. I have a html form to fill out, then the values are entered into the database. I have a hidden field for the date inside the form because I just want the date field to be automatically entered when I click the submit button. However, that is my trouble. When the submit button is clicked, I execute my php script that enters the information into the database...below is the query I use....
INSERT INTO callog VALUES (' ','$call_date','$call_first','$call_last','$call_phone','$call_mess')";
the first field is blank because I have an ID field that automatically increments itself. The next field is the name of the date field. I've tried everything I can think of, but obviously not the right thing because I know there is a way to do this. I don't know if it is a php script thing, or a setting in my database that I need to change.
INSERT INTO callog VALUES (' ','$call_date','$call_first','$call_last','$call_phone','$call_mess')";
the first field is blank because I have an ID field that automatically increments itself. The next field is the name of the date field. I've tried everything I can think of, but obviously not the right thing because I know there is a way to do this. I don't know if it is a php script thing, or a setting in my database that I need to change.
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Could you not change the SQL to:
as []InTeR[] suggested - NOW() will give you the date (and time if applicable) that the record was inserted.
Mac
Code: Select all
INSERT INTO callog VALUES (' ', NOW(), '$call_first', '$call_last', '$call_phone', '$call_mess')Mac
- cbcampbell
- Forum Newbie
- Posts: 19
- Joined: Mon Jun 09, 2003 12:12 am