On Thu, 2010-07-01 at 14:26 -0700, Don Wieland wrote: > In one of my forms, I am building a variable that I can use as an > INSERT string. > > On my form, I have several DATE fields which exist of 3 fields MM - DD > - YYYY > > when I build my string it looks like this: > > array('dbf'=>'applicant_dob', > 'f'=>array('applicant_dob_1','applicant_dob_2','applicant_dob_3'), > 'req'=>0, 's'=>'/'), > > This enters in the DB fine when there is a DATE, but when these fields > are left empty, it inserts into the the DB as 2069-12-31. > > How does one deal with this? > > Don Wieland > How are you allowing the user to select a date? If it is three form fields, it might be logical to use select lists with the allowed range of values in. If that's not possible, use lines like this to set default values: $month = (isset($_POST['month']) && preg_match('/^\d{2}$/', $_POST['month']))?$_POST['month']:'01'; which would set a default month value of '01' if there was either no month value sent or it wasn't a 2-digit value. Thanks, Ash http://www.ashleysheridan.co.uk