You are here:  » SQL Error Displayed in Price Table

SQL Error Displayed in Price Table

Submitted by ChrisNBC on Wed, 2016-11-30 15:45 in

Hi David,

Hope all is going well.

The error message below is being displayed in some of the pricing tables on the site I’m working on. Initially the product page displays the price information correctly but as soon as the results are filtered by size the error is displayed. I haven’t seen anything like this before in the pricing table and wondered if you might be able to suggest a way to resolve it.

[SELECT merchant FROM `pt_products` WHERE merchant IN () ORDER BY rand() LIMIT 1][You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ') ORDER BY rand() LIMIT 1' at line 1]

Thanks in advance.

Best regards

Submitted by support on Wed, 2016-11-30 16:00

Hi Chris,

I know you're using a heavily customised installation, I checked back through the latest files I have from you by email and your price comparison table is being generated by products.php (I think html/prices.php is empty) and this error relates to the product_adcode() function.

I see that elsewhere in the modified script, a PHP empty() call is used, I presumably as a function of the AJAX reloading after applying filters, so the same check can be used in the product_adcode() function to avoid the error, so where you have the following code around line 169:

    $merchants = array();

...REPLACE with:

    if (empty($prices)) return;
    $merchants = array();

Hope this helps!


Submitted by ChrisNBC on Wed, 2016-11-30 17:13

Hi David,

Thanks for the quick response. I updated the code above in prices_tbody.php and the problem appears to be resolved.

Best regards