User Edits/Updates Not Posting to MySql

  • Profile Image
    Asked on July 11, 2014 at 01:47 PM

    Hello - My form is is setup and posting perfect to MySql table - everything is working great. No errors and all my info is accessible.

    However, when the user clicks on the EDIT link in their auto responder email and makes any changes to the form the edits are not posting to my database.

    Is there any code samples that I can see to ensure that I have written mine correctly?

    I used the sample code that was posted here in the Form to write my POST custom thank you page.

    If you have any other ideas as to what might cause this prob, I'd love to hear....thank you :)

  • Profile Image
    Answered on July 11, 2014 at 02:36 PM

    In this case you should have a conditional statement that checks if the submissions ID exist, if it exist, it will update the submissions, otherwise if not, it will create a new data entry on the database, like this example:

    if ($resultcount > 0) {
        mysql_query("UPDATE `table_name` SET 
                                    `name` = '$name',
                                    `email` = '$email',
                                    `phone` = '$phonenumber',
                                    `subject` = '$subject',
                                    `message` = '$message'        
                                 WHERE `submission_id` = '$submission_id'"
         or die(mysql_error());
    else {

        mysql_query("INSERT INTO `table_name` (submission_id, formID, IP, 
                                                                              name, email, phone, subject, message) 
                                   VALUES ('$submission_id', '$formID', '$ip', 
                                                     '$name', '$email', '$phonenumber', '$subject', '$message') "
        or die(mysql_error());  



    You can take a look this guide "How to send Submissions to Your MySQL Database Using PHP". If you already did it, please provide us your code, so we can check further.

  • Profile Image
    Answered on July 11, 2014 at 09:13 PM

    Need help please - I'm sooo frustrated...

    No matter what form I try, I cannot get the user edits to submit to mysql db. I get an error EVERY TIME. The form data posts perfect the first time the user submits the form.

    But if they click on the EDIT link in their email, they get an error after pressing SUBMIT when they've made any changes to the form and their edits are not reflected in the db.

    I literally copied and pasted the sample code that is in the How-To-Send-Submissions-To-Your-Database Forum Post. So, I can't figure out how I can have an error? 

    This is my error:
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''email'='', 'dineragreement'='N/A', 'onsitesubmitted'='N/A' at line 2

    Here is my form:

    Here is my PHP (I have XXX out my DB user/pass):


    // 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




    $db_host = 'localhost';
    $db_username = 'XXXXXX';
    $db_password = 'XXXXXX';
    $db_name = 'XXXXXX';

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


    // search submission ID

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

    $sqlsearch = mysql_query($query);
    $resultcount = mysql_numrows($sqlsearch);

    if ($resultcount > 0) {

         mysql_query("UPDATE `jotstatus` SET 


                                 WHERE `submission_id` = '$submission_id'") 

         or die(mysql_error());

    } else {

        mysql_query("INSERT INTO `jotstatus` (submission_id,formID,ip,email,dineragreement,onsitesubmitted,finalreport,dineragreement18,onsitedone,finaldone,checkamp,checkimage,creditcard) 

                                   VALUES ('$submission_id','$formID','$ip','$email','$dineragreement','$onsitesubmitted','$finalreport','$dineragreement18','$onsitedone','$finaldone','$checkamp','$checkimage','$creditcard') ") 

        or die(mysql_error());  


    Any help you can provide is greatly appreciated....I have this same setup on 3 forms and I have this same problem on all 3. So it's obviously something I am not doing right...


    - Ellie



  • Profile Image
    Answered on July 12, 2014 at 03:53 AM

    Hi Ellie,

    We'll check this for you and get back to you later today.