Title: SQL syntax Error on Wishlist Search
Last modified: September 20, 2022

---

# SQL syntax Error on Wishlist Search

 *  Resolved [Vijay Hardaha](https://wordpress.org/support/users/vijayhardaha/)
 * (@vijayhardaha)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/sql-syntax-error-on-wishlist-search/)
 * I have found SQL Syntex Error while doing Wishlist Search, error is coming from
 * – file `includes/wishlist.class.php`
    – function `get()` – line `$sql = str_replace(
   $replace, $replacer, $default['sql'] );`
 * You have to use `$sql` in that line in place of `$default['sql']`

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

 *  Plugin Author [templateinvaders](https://wordpress.org/support/users/templateinvaders/)
 * (@templateinvaders)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/sql-syntax-error-on-wishlist-search/#post-16027143)
 * Hi [@vijayhardaha](https://wordpress.org/support/users/vijayhardaha/)
 * Could you post exactly SQL error details, please?
 * The mentioned method `get()` can accept a predefined SQL string attribute. You
   mentioned code that used to operate with SQL string passed outside, everything
   is correct in that case.
 *  Thread Starter [Vijay Hardaha](https://wordpress.org/support/users/vijayhardaha/)
 * (@vijayhardaha)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/sql-syntax-error-on-wishlist-search/#post-16027478)
 * Output of `$default['sql']`
 *     ```
       ORDER BY {order_by} {order} LIMIT {offset},{count};
       ```
   
 * Output of `$sql`
 *     ```
       SELECT * FROM wp_tinvwl_lists WHERE status='public' ORDER BY date DESC LIMIT 0,10;
       ```
   
 * Output of `$data`
 *     ```
       Array
       (
           [status] => status='public'
       )
       ```
   
 * Search input is also missing in queries.
 *  Thread Starter [Vijay Hardaha](https://wordpress.org/support/users/vijayhardaha/)
 * (@vijayhardaha)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/sql-syntax-error-on-wishlist-search/#post-16027562)
 * I tracked the issue, so in file `search.class.php` in function `htmloutput` there
   is a `$wpdb->prepare` which is failing because of this kind of SQL syntax.
 *     ```
       AND (CONCAT(A.display_name, ' ', A.user_email, ' ',B.meta_value) LIKE '%demo%' )
       ```
   
 * I am guessing `'%demo%'` becomes a placeholder inside `$wpdb->prepare`, hence
   prepare return empty value and in result, I am just getting
 *     ```
       ORDER BY 
       {order_by}
        {order} LIMIT {offset},{count};
       ```
   
 * in `$default['sql']`
    -  This reply was modified 3 years, 8 months ago by [Vijay Hardaha](https://wordpress.org/support/users/vijayhardaha/).
      Reason: fixed the code formatting
 *  Plugin Author [templateinvaders](https://wordpress.org/support/users/templateinvaders/)
 * (@templateinvaders)
 * [3 years, 8 months ago](https://wordpress.org/support/topic/sql-syntax-error-on-wishlist-search/#post-16029542)
 * [@vijayhardaha](https://wordpress.org/support/users/vijayhardaha/)
 * Thanks for the bug report.
 * It affects only when logged users get empty wishlists search results in the premium
   version of our plugin.
 * The fix is included in the upcoming update.

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

The topic ‘SQL syntax Error on Wishlist Search’ is closed to new replies.

 * ![](https://ps.w.org/ti-woocommerce-wishlist/assets/icon-256x256.gif?rev=2469447)
 * [TI WooCommerce Wishlist](https://wordpress.org/plugins/ti-woocommerce-wishlist/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ti-woocommerce-wishlist/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ti-woocommerce-wishlist/)
 * [Active Topics](https://wordpress.org/support/plugin/ti-woocommerce-wishlist/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ti-woocommerce-wishlist/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ti-woocommerce-wishlist/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [templateinvaders](https://wordpress.org/support/users/templateinvaders/)
 * Last activity: [3 years, 8 months ago](https://wordpress.org/support/topic/sql-syntax-error-on-wishlist-search/#post-16029542)
 * Status: resolved