• Resolved DDT

    (@ddt)


    Hi,

    I have a fresh clean WP install with the latest WPCF7 and it works ok. But when I add a
    add_action("wpcf7_before_send_mail", "add_to_database");

    WPCF7 is stuck with the spinning icon. It gives the following error
    <div class="ajax-error">Unexpected token < </div>

    My function add_to_database seems to work correctly as every item is saved in the table as expected.

    How can I fix the unexpected token issue???

    [edit] i enabled debugging and I see get this message:
    [22-Mar-2016 08:57:38 UTC] PHP Warning: mysqli_real_escape_string() expects parameter 2 to be string, array given in /Applications/XAMPP/xamppfiles/htdocs/mydomain.com/wp-includes/wp-db.php on line 1127

    IN my function I have
    $result = $wpdb->query($wpdb->prepare("INSERT INTO ......

    Regards

    https://wordpress.org/plugins/contact-form-7/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter DDT

    (@ddt)

    i have rewritten funciton add_to_database with

    $result = $wpdb->insert("custom_table", array(
                "approved" => NULL,
    Thread Starter DDT

    (@ddt)

    I also see

    <div class=”ajax-error”>JSON.parse: unexpected character at line 1 column 1 of the JSON data</div>

    Where/how can I see more information about JSON.parse: unexpected character at line 1 column 1 of the JSON data??

    I am using firefox+firebug but can’t seem to get more information

    ps: I already disabled all plugins and turn on theme twentyfiftheen

    Thread Starter DDT

    (@ddt)

    ok I narrowed it down to the following this CF7 shortcode
    [checkbox* free-payed id:free-payed class:free-payed label_first exclusive "Free" "Payed" "Friends"]

    seems not to be working correctly.

    $submission = WPCF7_Submission::get_instance();
            if ($submission) {
                $posted_data = $submission->get_posted_data();
     $free_payed = $posted_data["free-payed"];
    }

    but if I set
    $free_payed = ‘test’;
    the query works correctly

    Thread Starter DDT

    (@ddt)

    Ok, finally found a solution I had to add [0] as checkbox form field are seen as array’s

    $free_payed = $posted_data["free-payed"][0];

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Unexpected token’ is closed to new replies.