Current location: Hot Scripts Forums » Other Discussions » Database » datetime data type problem...


datetime data type problem...

Reply
  #1 (permalink)  
Old 10-04-06, 06:32 PM
Clark_Kent's Avatar
Clark_Kent Clark_Kent is offline
Newbie Coder
 
Join Date: Mar 2006
Posts: 60
Thanks: 0
Thanked 0 Times in 0 Posts
datetime data type problem...

Hi Everyone,

I have a form that submits data into a database with the use of PHP. I have a hidden form element that I created in order to input the current date and time into the database using the now() function once the form has been submitted (i'm using MySQL). The problem i'm experiencing is when the form has been submitted and the necessary form data is placed into the database, the datetime field is set to zeros instead of the current date and time - it displays 0000-00-00 00:00:00.

Input field looks like this...

Code:
<input type="hidden" name="dateJoined" value="now()"  />
The corresponding PHP code that deals with this specific control is the following...

Code:
GetSQLValueString($_POST['dateJoined'], "date")
The PHP code above i took out of the VALUES part of the SQL query. I know something is being sent to the datetime field in the database because it displays a series of zeros, I'm just not sure why it doesn't accept the current time and date from the now() function. When i enter the following query...

Code:
UPDATE databaseName.tableName SET dateJoined = now();
the above works, it updates the datetime field with the current date and time. So at least the now() function does input the correct data.

Any idea what I'm doing wrong?

Thanks for your time,

- CK
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 10-06-06, 11:09 AM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
I'll give it a guess, try any or all of the following -

now() is a mysql function. It only has a meaning and only results in a value when it appears in a mysql query.

Your GetSQLValueString(..) function is a user defined function. To get any help with what it might be doing, you need to post the code for it.

We would need to see the query string that results when the form is submitted in order to help.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 10-07-06, 12:16 PM
flann flann is offline
Newbie Coder
 
Join Date: Jun 2006
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Instead of passing the date through a form, when you do your insert statement try.

INSERT INTO tablename (dateField)
VALUES (CURDATE())

I like to spread the love between php and the database.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Default value for the Datetime data type... Clark_Kent Database 2 08-09-06 08:40 AM
visual basic problem I cannot solve: data grid : need vb programmer for hire chrismonroe10 Visual Basic 1 03-25-05 07:42 PM
Problem getting data from DataGrid on update petersza ASP.NET 5 10-20-04 12:37 AM


All times are GMT -5. The time now is 03:50 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.