Title: Query UPDATE give an SQL syntax error
Last modified: August 7, 2023

---

# Query UPDATE give an SQL syntax error

 *  [shecky](https://wordpress.org/support/users/shecky/)
 * (@shecky)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/query-update-give-an-sql-syntax-error/)
 * Good morning.
 * In my site I use the “YITH WooCommerce Product Add-Ons” plugin.
   Due to an error
   in the UPDATE query, the site is generating error_log files on the server of 
   over 4 Gb which make the site unusable.The problem is due to the query:
 * “**_UPDATE FqkM3Dbc2tyith\_wapo\_addons SET last\_update= CURRENT\_TIMESTAMP,
   settings …_**“
 * due to the fact that there are some single quotes (‘) in the serialized value
   text_content which causes the query to explode.
   I supposed this is due to the
   fact that “add_slashes” was not used before saving the value to DB.This is an
   example of text_content value that I try to insert:
 * _**“text\_content”;s:504:”Per l’asciugamano puoi scegliere la base e la decorazione.
   
   Sceglierò io il nastro da utilizzare per il bordo, in modo armonizzare i vari
   elementi che comporranno il Tuo set.Se ti serve l’etichetta, seleziona la voce
   relativa. A fine ordine andrai a scegliere il font e il testo da ricamare, in
   modo che le etichette siano tutte uguali.Non esitare a contattarmi (tasto WhatsApp
   a destra in basso!) se qualcosa dovesse esserti poco chiaro!(Puoi vedere alcuni
   esempi tra le foto della galleria).”
 * Can you check and fix the problem?
   Thanks!
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fquery-update-give-an-sql-syntax-error%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

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

 *  [crodriguez1991](https://wordpress.org/support/users/crodriguez1991/)
 * (@crodriguez1991)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/query-update-give-an-sql-syntax-error/#post-16952489)
 * Hello there,
 * I hope you’re doing well :D.
 * Could you please send me an screenshot where I can see where are you adding this
   message? It’s an addon description you are trying to add?
 * I made a test and I added your text as a description of an addon and seems to
   work fine. [See the following screenshots](https://sendgb.com/C8nbJ1vo7wy)
 * I’m looking forward your response.
 * Have a good day.
 *  Thread Starter [shecky](https://wordpress.org/support/users/shecky/)
 * (@shecky)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/query-update-give-an-sql-syntax-error/#post-16954035)
 * Hi Carlos!
 * Message is an HTML Text inside a custom block created with plugin.
 * Screenshot are here:
 * [https://notonlyteddy.com/Screenshot1.png](https://notonlyteddy.com/Screenshot1.png)
 * [https://notonlyteddy.com/Screenshot2.png](https://notonlyteddy.com/Screenshot2.png)
 * [https://notonlyteddy.com/Screenshot3.png](https://notonlyteddy.com/Screenshot3.png)
 * Regards.
   Davide.
 *  Thread Starter [shecky](https://wordpress.org/support/users/shecky/)
 * (@shecky)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/query-update-give-an-sql-syntax-error/#post-16958693)
 * Hi [@crodriguez1991](https://wordpress.org/support/users/crodriguez1991/) !
 * Same good news for me?
 * Regards.
   Davide.
 *  [crodriguez1991](https://wordpress.org/support/users/crodriguez1991/)
 * (@crodriguez1991)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/query-update-give-an-sql-syntax-error/#post-16959896)
 * Hello there,
 * I hope you’re doing well :D.
 * We created the following code in order to regenerate the tables and execute the
   migration process again.
 * Please, try to add the following code in the functions.php of your active theme
 *     ```wp-block-code
       if ( ! function_exists( 'yith_wapo_check_db_400' ) ) {
           function yith_wapo_check_db_400() {
   
               // Add ?yith_addons=1 to the URL inside the admin panel will execute all the code.
               if ( isset( $_GET['yith_addons'] ) ) {
   
                   global $wpdb;
                   require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
   
                   $blocks_table = $wpdb->prefix . 'yith_wapo_blocks';
                   $assoc_table = $wpdb->prefix . 'yith_wapo_blocks_assoc';
   
                   $charset_collate = $wpdb->get_charset_collate();
   
                   // 1. BLOCKS TABLE - START
                   $sql_blocks = "CREATE TABLE {$wpdb->prefix}yith_wapo_blocks (
                               id                  INT(3) NOT NULL AUTO_INCREMENT,
                               user_id             BIGINT(20),
                               vendor_id           BIGINT(20),
                               settings            LONGTEXT,
                               priority            DECIMAL(9,5),
                               visibility          INT(1),
                               creation_date       TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
                               last_update         TIMESTAMP,
                               name                varchar(255) NOT NULL,
                               product_association varchar(255),
                               exclude_products    tinyint(1) NOT NULL,
                               user_association    varchar(255),
                               exclude_users       tinyint(1) NOT NULL,
                               PRIMARY KEY (id)
                           ) $charset_collate;";
   
                   if ( function_exists( 'maybe_create_table' ) ) {
                       maybe_create_table( $blocks_table, $sql_blocks );
                   }
   
                   // CREATE COLUMNS FOR BLOCKS TABLE.
                   $blocks_columns = array(
                       'name'                => 'ALTER TABLE ' . $blocks_table . ' ADD name varchar(255) NOT NULL;',
                       'product_association' => 'ALTER TABLE ' . $blocks_table . ' ADD product_association varchar(255);',
                       'exclude_products'    => 'ALTER TABLE ' . $blocks_table . ' ADD exclude_products tinyint(1) NOT NULL;',
                       'user_association'    => 'ALTER TABLE ' . $blocks_table . ' ADD user_association varchar(255);',
                       'exclude_users'       => 'ALTER TABLE ' . $blocks_table . ' ADD exclude_users tinyint(1) NOT NULL;',
                   );
   
                   foreach ( $blocks_columns as $block_column => $block_statement ){
                       if ( function_exists( 'maybe_add_column' ) ) {
                           maybe_add_column($blocks_table, $block_column, $block_statement);
                       }
                   }
   
                   // BLOCKS TABLE - END
   
                   // 2. BLOCKS ASSOC TABLE - START
   
                   $sql_associations = "CREATE TABLE {$wpdb->prefix}yith_wapo_blocks_assoc (
                               rule_id bigint(20) NOT NULL,
                               object varchar(255) NOT NULL,
                               type varchar(50) NOT NULL,
                               KEY type (type),
                               KEY object (object)
                           ) $charset_collate;";
   
                   if ( function_exists( 'maybe_create_table' ) ) {
                       maybe_create_table($assoc_table, $sql_associations);
                   }
   
                   // CREATE COLUMNS FOR ASSOCIATION TABLE.
                   $assoc_columns = array(
                       'rule_id' => 'ALTER TABLE ' . $assoc_table . ' ADD rule_id varchar(255) NOT NULL;',
                       'object'  => 'ALTER TABLE ' . $assoc_table . ' ADD object varchar(255) NOT NULL;',
                       'type'    => 'ALTER TABLE ' . $assoc_table . ' ADD type varchar(50) NOT NULL;',
                   );
   
                   foreach ( $assoc_columns as $assoc_column => $assoc_statement ){
                       if ( function_exists( 'maybe_add_column' ) ) {
                           maybe_add_column($assoc_table, $assoc_column, $assoc_statement);
                       }
                   }
   
                   // BLOCKS ASSOC TABLE - END
   
                   // 3. UPDATE OPTION - START
                   update_option( 'yith_wapo_db_update_scheduled_for', '2.0.0' );
                   update_option( 'yith_wapo_db_version_option', '2.0.0' );
                   //UPDATE OPTION - END
   
               }
           }
           add_action( 'admin_init', 'yith_wapo_check_db_400' );
       }
       ```
   
 * Then try to visit your site adding the following url
 * [https://yoursite.com/wp-admin/admin.php?page=yith_wapo_panel&yith_addon=1](https://yoursite.com/wp-admin/admin.php?page=yith_wapo_panel&yith_addon=1)
 * Note: you need to change yoursite.com and add your domain.
 * Note2: I suggest you to execute the code on a staging site before to set it on
   production. In this way you’ll prevent to generate problems on your production
   site.
 * Please, try it and let me know.
 * Have a good day

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

The topic ‘Query UPDATE give an SQL syntax error’ is closed to new replies.

 * ![](https://ps.w.org/yith-woocommerce-product-add-ons/assets/icon-128x128.gif?
   rev=3142291)
 * [YITH WooCommerce Product Add-Ons](https://wordpress.org/plugins/yith-woocommerce-product-add-ons/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/yith-woocommerce-product-add-ons/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/yith-woocommerce-product-add-ons/)
 * [Active Topics](https://wordpress.org/support/plugin/yith-woocommerce-product-add-ons/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/yith-woocommerce-product-add-ons/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/yith-woocommerce-product-add-ons/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [crodriguez1991](https://wordpress.org/support/users/crodriguez1991/)
 * Last activity: [2 years, 10 months ago](https://wordpress.org/support/topic/query-update-give-an-sql-syntax-error/#post-16959896)
 * Status: not resolved