Title: SQL syntax error confused
Last modified: August 30, 2016

---

# SQL syntax error confused

 *  Resolved [msagovac](https://wordpress.org/support/users/msagovac/)
 * (@msagovac)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/sql-syntax-error-confused/)
 * I’m using latest version of your plugin and logs dumps with SQL errors for example:
 * 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‘
   WHERE `term_ID` = 38 AND `language` = ‘en_US” at line 3 for query SELECT `name`
   
   logs/error.log: WHERE `term_ID` = 38 AND `language` = ‘en_US’
 * Errors are always same on all page instead index. I’ve tried to search where 
   is term_ID query and this is only your plugin and taxonomy:
 * # grep -rl “term_ID”
    logs/error.log wp-includes/taxonomy.php wp-content/plugins/
   multilanguage/multilanguage.php
 * Searched in multilanguage.php and tried var_dump such as on all:
 * var_dump($item->object_id,$mltlngg_current_language); die();
 * I’ve got on admin page “NULL” “en_US”. There are some SQL error on it but i’m
   not sure why errors still shows. Errors dumps only on log file.
 * Tried to disable plugin, and error doesn’t show.
 * [https://wordpress.org/plugins/multilanguage/](https://wordpress.org/plugins/multilanguage/)

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

 *  Plugin Author [bestwebsoft](https://wordpress.org/support/users/bestwebsoft/)
 * (@bestwebsoft)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/sql-syntax-error-confused/#post-6610430)
 * Hi,
 * We have received your query and it is now being processed. We will get back to
   you on this forum as soon as we can.
 * Regards,
    BestWebSoft Support Team
 *  Plugin Author [bestwebsoft](https://wordpress.org/support/users/bestwebsoft/)
 * (@bestwebsoft)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/sql-syntax-error-confused/#post-6610479)
 * Hi,
 * We’ll examine our plugin to the existence of the problem and we’ll fix it. Also,
   please specify the place you’ve added the following code (the row number)
    `var_dump(
   $item->object_id,$mltlngg_current_language); die();?`
 * Sincerely,
    BestWebSoft Support Team
 *  Thread Starter [msagovac](https://wordpress.org/support/users/msagovac/)
 * (@msagovac)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/sql-syntax-error-confused/#post-6610482)
 * Hello,
 * I’ve put all var_dump and triggers on errors on line 504 or code:
 * /* Display categories list & tags cloud & categories/tags of posts in the selected
   language */
    if ( ! function_exists( ‘mltlngg_terms_filter’ ) ) { function mltlngg_terms_filter(
   $terms ) { global $mltlngg_terms_table_translate, $wpdb, $mltlngg_current_language;
   foreach ( $terms as $mltlngg_one_term ) { if ( isset( $mltlngg_one_term->term_id)){
   $mltlngg_one_term_name = $wpdb->get_var( $wpdb->prepare( “SELECT `name` FROM 
   $mltlngg_terms_table_translate WHERE `term_ID` = %d AND `language` = ‘%s’ “, 
   $mltlngg_one_term->term_id, $mltlngg_current_language ) ); //var_dump(‘5>>’.$
   item->object_id,$mltlngg_current_language); die(); if ( isset( $mltlngg_one_term_name)&&“”!
   = $mltlngg_one_term_name ) /* If translation is exist and not empty, filter terms*/
   $mltlngg_one_term->name = $mltlngg_one_term_name; } } return $terms; } }
 * A response on landing page and admin is:
 * string(3) “5>>” string(5) “en_US”
 *  Plugin Author [bestwebsoft](https://wordpress.org/support/users/bestwebsoft/)
 * (@bestwebsoft)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/sql-syntax-error-confused/#post-6610495)
 * Hi,
 * You’re doing `var_dump` of the element `$item->object_id` in the function where
   it does not exist. Accordingly, as a result you receive “NULL”. This variable
   is appeared in the our plugin’s code in the function `mltlngg_nav_menu_items_filter()`.
   So if you’ll do `var_dump` of this variable here, you’ll make sure that it is
   filled with data correctly and worked out in accordance with its functionality.
   The error you’ve described may be generated due to the MariaDB database syntax
   features. Our plugins are developed and tested using MySQL database, so we can’t
   reproduce this error. If you’ll find a solution, we’d be grateful if you tell
   it to us.
 * Sincerely,
    BestWebSoft Support Team
 *  Thread Starter [msagovac](https://wordpress.org/support/users/msagovac/)
 * (@msagovac)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/sql-syntax-error-confused/#post-6610499)
 * Hello,
 * I found where is problem. A variable $mltlngg_terms_table_translate returns NULL.
   This means that as string is “”. NULL === “”
 * Example:
 * If I dump this:
 * if ( ! function_exists( ‘mltlngg_terms_filter’ ) ) {
    function mltlngg_terms_filter(
   $terms ) { global $mltlngg_terms_table_translate, $wpdb, $mltlngg_current_language;
   foreach ( $terms as $mltlngg_one_term ) { if ( isset( $mltlngg_one_term->term_id)){
   $mltlngg_one_term_name = $wpdb->get_var( $wpdb->prepare( “SELECT `name` FROM 
   $mltlngg_terms_table_translate WHERE `term_ID` = %d AND `language` = ‘%s’ “, 
   $mltlngg_one_term->term_id, $mltlngg_current_language ) );
 *  var_dump($mltlngg_terms_table_translate); die(); // RETURNS NULL
 * OR A FULL QUERY IS:
    SELECT `name` FROM WHERE `term_ID` = 49 AND `language` =‘
   en_US’
 * So after i tried to find where is variable $mltlngg_terms_table_translate and
   refer to table name “wp_mltlngg_terms_translate”.
 * Then in SQL query check for table:
 * MariaDB [—]> select * from wp_mltlngg_terms_translate;
    Empty set (0.00 sec)
 * Okay, than i changed a code and instead of null of name table i changed to string:
 * “SELECT `name`
    FROM wp_mltlngg_terms_translate WHERE `term_ID` = %d AND `language`
   = ‘%s’ “
 * and in a LOG IS NOW CLEAN. No errors shown. Didn’t received a table name “wp_mltlngg_terms_translate”.
 * Doesn’t know why, but i think is problem that a function didn’t received in other
   function from:
 * $mltlngg_terms_table_translate = $wpdb->prefix . ‘mltlngg_terms_translate’;
 * Create table:
 * MariaDB [—]> show create table wp_mltlngg_terms_translate;
    +—————————-+—————————————————————————————————————————————————————————————————————————————-
   + | Table | Create Table | +—————————-+—————————————————————————————————————————————————————————————————————————————-
   + | wp_mltlngg_terms_translate | CREATE TABLE `wp_mltlngg_terms_translate` ( `
   ID` int(6) unsigned NOT NULL AUTO_INCREMENT, `term_ID` int(6) NOT NULL, `name`
   text NOT NULL, `language` text NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT
   CHARSET=utf8 | +—————————-+—————————————————————————————————————————————————————————————————————————————-
   + 1 row in set (0.00 sec)
 *  Plugin Author [bestwebsoft](https://wordpress.org/support/users/bestwebsoft/)
 * (@bestwebsoft)
 * [10 years, 6 months ago](https://wordpress.org/support/topic/sql-syntax-error-confused/#post-6610508)
 * Hi,
 * The variable `$mltlngg_terms_table_translate` is initialized with `$wpdb->prefix.'
   mltlngg_terms_translate';` in the function `mltlngg_init` (file ‘mltlngg_init’,
   line 62).
    And the function `mltlngg_init` is used in the hook `add_action( '
   init', 'mltlngg_init', 9 );`, which is triggered before the hooks `add_filter('
   get_terms', 'mltlngg_terms_filter' );` and `add_filter( 'get_the_terms', 'mltlngg_terms_filter');`.
   Accordingly, the variable `$mltlngg_terms_table_translate` should already be 
   initialized by the necessary value at the time of the function `mltlngg_init`
   is called.
 * Perhaps, some of the activated plugins or your theme affect the hook `init` implementation.
 * So, we kindly ask you to complete the following steps:
 * 1) Please try activating a standard WP theme for a while (2014, 2015) and check
   if the problem remains.
    2) Please try deactivating all of your plugins except
   Multilanguage and also check if the problem is still present. If it is not, please
   activate the plugins one-by-one, meanwhile checking, after which plugin activation
   the problem appears again. 3) Please provide your System status as well. Follow
   the next instruction – [https://docs.google.com/document/d/1Wi2X8RdRGXk9kMszQy1xItJrpN0ncXgioH935MaBKtc/edit](https://docs.google.com/document/d/1Wi2X8RdRGXk9kMszQy1xItJrpN0ncXgioH935MaBKtc/edit)
   4) Please let us know about the results.
 * Sincerely,
    BestWebSoft Support Team
 *  Plugin Author [bestwebsoft](https://wordpress.org/support/users/bestwebsoft/)
 * (@bestwebsoft)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/sql-syntax-error-confused/#post-6610546)
 * Hi,
 * Since there is no reply from you, we consider this topic as resolved. We hope
   you’ve found the solution. If you have any questions, please feel free to contact
   us via our Help Center – [http://support.bestwebsoft.com/](http://support.bestwebsoft.com/).
 * Sincerely,
    BestWebSoft Support Team

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

The topic ‘SQL syntax error confused’ is closed to new replies.

 * ![](https://ps.w.org/multilanguage/assets/icon-256x256.gif?rev=2565228)
 * [Multilanguage by BestWebSoft - WordPress Translation Plugin and Language Switcher](https://wordpress.org/plugins/multilanguage/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/multilanguage/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/multilanguage/)
 * [Active Topics](https://wordpress.org/support/plugin/multilanguage/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/multilanguage/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/multilanguage/reviews/)

## Tags

 * [sql](https://wordpress.org/support/topic-tag/sql/)

 * 7 replies
 * 2 participants
 * Last reply from: [bestwebsoft](https://wordpress.org/support/users/bestwebsoft/)
 * Last activity: [9 years, 9 months ago](https://wordpress.org/support/topic/sql-syntax-error-confused/#post-6610546)
 * Status: resolved