Jump to content

Recommended Posts

Hello,

I'm having a problem with an SQL datetime field. The field is set to allow nulls and that it has no default value but when I submit the PHP form the datetime field gets updated to 01/01/1970 12:00:00:00 AM. Can anyone tell me whats going on!? I want to have the null values!

 

Thanks for your help!

Link to comment
https://forums.phpfreaks.com/topic/51843-date-field-defaults-to-01011970/
Share on other sites

Dates are set with a timestamp that is n seconds from a baseline date, in this case the one you see above. I suspect your query is setting the date with a null string when the date has no value. Instead try changing the query so that it is not setting the date at all or use NULL.

 

Post the code you use to build/run the query for more help.

Hi Guys,

Here's the code I use for the update, all of the variables are captured using $_POST['Field_Name'].

 

 

<?php
$sql_Insert="UPDATE tbl_Attendees SET Payment_Recieved='$date_PR_formatted',Payment_Method='$Payment_Method',Confirmation_Date='$date_CD_formatted',Training_Pack='$date_TP_formatted',Certificate_Date='$date_Cert_formatted' WHERE Person_ID='$Person_ID' AND Course_ID='$Course_ID'";
$Insert_Details=odbc_exec($conn,$sql_Insert);
if (!$Insert_Details)
{exit("Error in SQL");}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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