• FormCraft v1.2.11, WP 6.8.1

    Getting the following error when attempting to edit a form:

    [05-May-2025 20:05:08 UTC] WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''wpws_formcraft_b_forms' WHERE id = 5' at line 1 for query SELECT * FROM 'wpws_formcraft_b_forms' WHERE id = 5 made by do_action('toplevel_page_formcraft_basic_dashboard'), WP_Hook->do_action, WP_Hook->apply_filters, formcraft_basic_dashboard, require_once('/plugins/formcraft-form-builder/views/builder.php')

    I’ve traced this to the following line in builder.php

    $qry = $wpdb->get_results( $wpdb->prepare("SELECT * FROM %s WHERE id = %d", $forms_table, $form_id));

    Preparing the statement in this fashion includes the table name as a single quoted string, which causes the error. I’ve resolved this issue by updating the code:

    $qry = $wpdb->get_results( $wpdb->prepare("SELECT * FROM $forms_table WHERE id = %d", $form_id));

    —-

    There’s another syntax error in formcraft-main.php, line 473. There’s an extra comma following the table name in the statement.

    Continuing to troubleshoot here and will fix these issues locally, but I hope that they can be addressed by a future update.

    Thanks!

The topic ‘SQL Syntax Errors’ is closed to new replies.