Loading jotform form data to mysql database - php script error

  • Profile Image
    Asked on April 26, 2013 at 09:21 AM



    Thanks for the script. It works as charm for me. The only one problem I have is that when I include the item "file" for the submitted document. The thank you page shows me that : Unknown column 'file' in 'field list'


    That's the code I have:





    // 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'];

    $formID = $_POST['formID'];

    $ip = $_POST['ip'];

    $name = $_POST['name'];

    $email = $_POST['email'];

    $phonenumber = $_POST['phonenumber13'][0] ."-". $_POST['phonenumber13'][1];

    $subject = $_POST['subject7'];

    $message = $_POST['message6'];

    $file = $_POST['file'];




    mysql_connect( $db_host, $db_username, $db_password) or die(mysql_error());



    // search submission ID


    $query = "SELECT * FROM `candidates` WHERE `submission_id` = '$submission_id'";

    $sqlsearch = mysql_query($query);

    $resultcount = mysql_numrows($sqlsearch);


    if ($resultcount > 0) {


    mysql_query("UPDATE `candidates` SET

    `name` = '$name',

    `email` = '$email',

    `phone` = '$phonenumber',

    `subject` = '$subject',

    `message` = '$message'

    `file` = '$file'

    WHERE `submission_id` = '$submission_id'")

    or die(mysql_error());


    } else {


    mysql_query("INSERT INTO `candidates` (submission_id, formID, IP,

    name, email, phone, subject, message,file)

    VALUES ('$submission_id', '$formID', '$ip', '$name', '$email', '$phonenumber', '$subject', '$message','$file') ")

    or die(mysql_error());




    Thank you! Your submission has been received.

    This is a re-post of a comment on How to send Submissions to Your MySQL Database Using PHP

  • Profile Image
    Answered on April 26, 2013 at 09:35 AM

    I recommend changing your mysql password since you publicly posted your password on the comment. I removed it from the post but you might want to change it anyways. 

    The error message comes from mysql. This query is incorrect:

    mysql_query("INSERT INTO `candidates` (submission_id, formID, IP, name, email, phone, subject, message,file)

    Your candidates table does not have a file field. Either add that field or change the field name to the correct column name. 


  • Profile Image
    Answered on April 29, 2013 at 04:20 AM

    Hello Aytekin, 

    Thanks for the reply, it was very useful. 

    As you were right, I forgot to include the table in the database. Now when I submit the application, it recognize the name of the file I upload, but it's not working as a link. In the database is stored as a VARCHAR, 250 characters of length.


    I did a test uploading the file: analytics review website.pdf

    and in the file were I call the data from the database comes as:

    Analytics Review Website.pdf   

    (but not clickable)

    It will great if you can help me to understand what is the problem.

    Thanks again!  

  • Profile Image
    Answered on April 29, 2013 at 10:44 AM


    We'll try to get back to you later today for the solution on how you can retrieve the download link. I think there's something you need to do to have this.



  • Profile Image
    Answered on April 29, 2013 at 02:21 PM

    Thanks Welvin, 


    I´m looking forward to your response.


  • Profile Image
    Answered on April 29, 2013 at 03:23 PM

    Hello embscareers.  Unfortunately, the download link is not available from the post data.  However, you can manually create the download link based from the post data provided to your page

    Coming from the variables you have shared, you can build the link and print it by following this:

     $linkfile = "http://www.jotform.com/uploads/embscareers/". $formID ."/". $submission_id ."/". $file;

    So assuming that you have these following details:

         $formID = 31112954391349
         $submission_id = 233031863471974555
         $file = Analytics Review Website.pdf

    It will then form this URL:

         http://www.jotform.com/uploads/embscareers/31112954391349/233031863471974555/Analytics Review Website.pdf

    Now, if you want it to be clickable, simply do this:

        <a href="<? echo $linkfile; ?>"> <?php echo $linkfile; ?> </a>

    I'm not sure if you get the idea of what I'm explaining, but if you have further questions, just throw 'em in, and we'll answer :)

  • Profile Image
    Answered on May 25, 2013 at 02:42 PM

    Get error message rid of due to mysql recovery, article open to you all solutions solve like troubles

  • Profile Image
    Answered on May 26, 2013 at 05:10 AM

    Hey guys


    Sorry @Liyam for my delayed answer, but the first part of your solution  worked like charm! :)

    Now Im gonna try with the clickable feature.


    Thank you very much!

    You guys are great:)

  • Profile Image
    Answered on May 26, 2013 at 11:07 AM



    Thank you for updating us. We're glad to know that the solution by Liyam works for you.

    Contact us again anytime should you have other question.


    Best Regards,

  • Profile Image
    Answered on May 29, 2013 at 07:49 AM


    It semms that you mysql database is corrupted so you face this problem,you can try to use Kernel for MySQL Database Recovery software, which efficiently repairs MyIASM format database and generates the required data. It also allows accessing the MySQL database from any remote place in the network and save the recovered data.

  • Profile Image
    Answered on July 04, 2013 at 11:28 PM

    We are happy to announce that we have released Jotform Webhooks,  this feature would replace Send Post Data + Custom URL Thank You Page workaround in order to help you transfer forms data to your own database using your own script codes.

    To know more about Jotform Webhooks, please click here.


    Thank you for using JotForm. :)

  • Profile Image
    Answered on July 05, 2013 at 03:35 AM



    Thanks for the info. My question is, if I actually have something set up with send post data + custom URL thank you, it will not work anymore?  

  • Profile Image
    Answered on July 05, 2013 at 04:24 AM


    No, they should still work. They are still available on the form preferences. Webhook is a more advanced one but you can still make use of the post data + custom URL.