I can not get my birthdate value to insert into my sql tabe.

  • Profile Image
    Asked on July 20, 2016 at 07:44 AM

    I used the php code in one of your forums and it worked with a phone number entry....not the date.  (Vhttps://www.jotform.com/answers/161213-How-can-I-insert-the-date-into-only-one-field-in-my-MySQL).

    Here is my code.....Its all BirthDate entry's:



    // This function will run within each post array including multi-dimensional arrays 

    function ExtendedAddslash(&$params)

            foreach ($params as &$var) {

                // check if $var is an array. If yes, it will start another ExtendedAddslash() function to loop to each key inside.

                is_array($var) ? ExtendedAddslash($var) : $var=addslashes($var);




         // Initialize ExtendedAddslash() function for every $_POST variable


    $submission_id = $_POST['submission_id'];

    $firstName3 = $_POST['fullname3']['0'];

    $middleName3 = $_POST['fullname3']['1'];

    $lastName3 = $_POST['fullname3']['2'];

    $phoneNumber5 = $_POST['phonenumber5']['0'] ."-". $_POST['phonenumber5']['1'];

    $email122 = $_POST['email122'];

    $address4 = $_POST['address4']['0'] ." ". $_POST['address4']['1'] ." ". $_POST['address4']['2'] ." ". $_POST['address4']['3'] .", ". $_POST['address4']['4'] ." ". $_POST['address4']['5'];

    $firstName16 = $_POST['fullname16']['0'];

    $middleName16 = $_POST['fullname16']['1'];

    $lastName16 = $_POST['fullname16']['2'];

    $firstName30 = $_POST['fullname30']['0'];

    $middleName30 = $_POST['fullname30']['1'];

    $lastName30 = $_POST['fullname30']['2'];

    $firstName25 = $_POST['fullname25']['0'];

    $middleName25 = $_POST['fullname25']['1'];

    $lastname25 = $_POST['fullname25']['2'];

    $firstName45 = $_POST['fullname45']['0'];

    $middleName45 = $_POST['fullname45']['1'];

    $lastName45 = $_POST['fullname45']['2'];

    $firstName37 = $_POST['fullname37']['0'];

    $middleName37 = $_POST['fullname37']['1'];

    $lastName37 = $_POST['fullname37']['2'];

    $relationTo19 = $_POST['relationto19'];

    $relationTo26 = $_POST['relationto26'];

    $relationTo39 = $_POST['relationto39'];

    $relationTo31 = $_POST['relationto31'];

    $relationTo47 = $_POST['relationto47'];

    $birthDate6 = $_POST['birthDate6']['2'] ."-". $_POST['birthDate6']['0'] ."-". $_POST['birthDate6']['1'];

    $birthDate18 = $_POST['birthDate18']['2'] ."-". $_POST['birthDate18']['0'] ."-". $_POST['birthDate18']['1'];

    $birthDate34 = $_POST['birthDate34']['2'] ."-". $_POST['birthDate34']['0'] ."-". $_POST['birthDate34']['1'];

    $birthDate32 = $_POST['birthDate32']['2'] ."-". $_POST['birthDate32']['0'] ."-". $_POST['birthDate32']['1'];

    $birthDate46 = $_POST['birthDate46']['2'] ."-". $_POST['birthDate46']['0'] ."-". $_POST['birthDate46']['1'];

    $birthDate38 = $_POST['birthDate38']['2'] ."-". $_POST['birthDate38']['0'] ."-". $_POST['birthDate38']['1'];

    $sex = $_POST['sex'];

    $sex28  = $_POST['sex28'];

    $sex21  = $_POST['sex21'];

    $sex40  = $_POST['sex40'];

    $sex33  = $_POST['sex33'];

    $sex48  = $_POST['sex48'];

    $listAny124  = $_POST['listany124'];

    $ifNot  = $_POST['ifnot'];

    $member1  = $_POST['member1'];

    $member2127  = $_POST['member2127'];

    $member129  = $_POST['member129'];

    $amountPer49  = $_POST['amountper49'];

    $amountPer  = $_POST['amountper'];

    $amountPer55  = $_POST['amountper55'];

    $amountPer100  = $_POST['amountper100'];

    $otherIncome  = $_POST['otherincome'];

    $howMuch63  = $_POST['howmuch63'];

    $howMuch64  = $_POST['howmuch64'];

    $ifYou  = $_POST['ifyou'];

    $whatIs  = $_POST['whatis'];

    $whatIs69  = $_POST['whatis69'];

    $whatIs70  = $_POST['Whatis70'];

    $ifYou135 = $_POST['ifyou135'];

    $haveYou72  = $_POST['haveyou72'];

    $areYou74  = $_POST['areyou74'];

    $areYou  = $_POST['areyou'];

    $haveYou84  = $_POST['haveyou84'];

    $haveYou78  = $_POST['haveyou78'];

    $areYou77  = $_POST['areyou77'];

    $pleaseList86  = $_POST['pleaselist86'];

    $pastlandlords = $_POST['pastlandlords'] ." ". $_POST['input80'] ."-". $_POST['input81'] ."-". $_POST['input82']['0'] ."-". $_POST['input82']['1'];

    $haveYou  = $_POST['haveyou'];

    $ifYes88  = $_POST['ifyes88'];

    $applicantsSignature  = $_POST['applicantssignature'];

    $date = $_POST['clickto104'];

    $input80 = $_POST['input80'];

    $input81 = $_POST['input81'];


    $link = mysql_connect('vidaliahousingorg.ipagemysql.com', 'vidaliaha', 'hav110'); 

    if (!$link) { 

        die('Could not connect: ' . mysql_error()); 


    mysql_select_db("applications", $link);


    $sql="INSERT INTO online (submission_id, firstName3, middleName3, lastName3, phoneNumber5, email122, address4, firstName16,  middleName16,  lastName16, firstName30,  middleName30,  lastName30, firstName25,  middleName25,  lastName25, firstName45, middleName45,  lastName45, firstName37, middleName37, lastName37, relationTo19, relationTo26, relationTo39, relationTo31, relationTo47, birthDate6, birthDate18, birthDate34, birthDate32, birthDate46, birthDate38, sex, sex28, sex21, sex40, sex33, sex48, listAny124, ifNot, member1, member2127, member129, amountPer49, amountPer, amountPer55, amountPer100, otherIncome, howMuch63, howMuch64, ifYou, whatIs, whatIs69, whatIs70, ifYou135, haveYou72, areYou74, areYou, haveYou84, haveYou78, areYou77, pleaseList86, haveYou, ifYes88, applicantsSignature, pastlandlords, date, input80, input81)


    ('$submission_id', '$firstName3', '$middleName3', '$lastName3', '$phoneNumber5', '$email122', '$address4', '$firstName16', '$middleName16', '$lastName16', '$firstName30', '$middleName30', '$lastName30', '$firstName25', '$middleName25', '$lastName25', '$firstName45', '$middleName45', '$lastName45', '$firstName37', '$middleName37', '$lastName37', '$relationTo19', '$relationTo26', '$relationTo39', '$relationTo31', '$relationTo47', '$birthDate6', '$birthDate18', '$birthDate34', '$birthDate32', '$birthDate46', '$birthDate38', '$sex', '$sex28', '$sex21', '$sex40', '$sex33', '$sex48', '$listAny124', '$ifNot', '$member1', '$member2127', '$member129', '$amountPer49', '$amountPer', '$amountPer55', '$amountPer100', '$otherIncome', '$howMuch63', '$howMuch64', '$ifYou', '$whatIs', '$whatIs69', '$whatIs70', '$ifYou135', '$haveYou72', '$areYou74', '$areYou', '$haveYou84', '$haveYou78', '$areYou77', '$pleaseList86', '$haveYou', '$ifYes88', '$applicantsSignature', '$pastlandlords', '$date', '$input80', '$input81'  )";



    if (!mysql_query($sql,$link))


      die('Error: ' . mysql_error());






  • Profile Image
    Answered on July 20, 2016 at 11:06 AM

    We will check your codes and get back to you with updates. Stay tuned!

  • Profile Image
    Answered on July 20, 2016 at 11:24 AM

    I think the problem is related with the casing on the birth date array keys. Note that with PHP, array names/keys are case sensitive. Please make them all in lowercase to resolve the problem.



    $birthDate6 = $_POST['birthDate6']['2'] ."-". $_POST['birthDate6']['0'] ."-". $_POST['birthDate6']['1'];


    $birthDate6 = $_POST['birthdate6']['2'] ."-". $_POST['birthdate6']['0'] ."-". $_POST['birthdate6']['1'];

    All should be in lowercase (check the bold letters above). Please do this to the other arrays and that should fix it.

    Hope this helps!

  • Profile Image
    Answered on July 29, 2016 at 10:10 AM

    Thanks for the quick response....Changed the casing on all array keys and still doesn't work.  I then tried to remove the hyphen in between the array keys, this didn't work either.  Any other ideas.    

  • Profile Image
    Answered on July 29, 2016 at 11:23 AM

    YOu can easily get the proper variable names and php codes by using first the URL https://www.jotform.com/show-post-data/  in the Thank you redirect of the form that send post data.




    What I suggeset you try also for testing is to minimize the number of field you were trying to test. Like, try using only the BirthDate field and remove first all the other fields.

    You can troubleshoot simpler and detect if the sql insert was really getting the correct value (or not just null)

    Try creating a clone of your long form and remove first all the other fields and retain only those BirthDate fields. Then test the send post data method and database insert function.

    Hope this help. Let us know how it goes.