You are here:  » Error mysql query if product have character accent


Error mysql query if product have character accent

Submitted by smartprice24 on Thu, 2018-01-11 10:21 in

Hi David.

As an object, products that contain special characters in the product name (é, è, ç, ò, à, etc), when i click on the link to the product page, from the search results, i have this error:

[SELECT DISTINCT(name) FROM `pt_products` WHERE LIMIT 5][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 'LIMIT 5' at line 1]

My table sql products is:

{code saved}

My product.php

{code saved}

I have fulltext enabled in other fields. However for new choice, I have disabled fulltext config.php.

In addition, accented characters in url are not shown correctly.

ES URL for product Bialetti 0800001 Coffee filter parti e accessori per macchina per il caffè

/prodotto/bialetti-0800002-coffee-filter-parti-e-accessori-per-macchina-per-il-caff%3F.html

Is possible replace only url accent characters with non-accent characters

Any advice or solution is well received

Thanks David

Giuseppe

Submitted by support on Thu, 2018-01-11 11:05

Hello Giuseppe,

The error appears to be the Related Products query, I see that you have the final WHERE clause commented out (I think due to not using FULLTEXT) so in the case of a product not found $where would be empty breaking the SQL - to correct this, where you have the following code beginning at line 152 in products.php:

    if (FALSE)
    {
      $wheres[] = "MATCH name AGAINST ('".database_safe($q)."')";
    }

...REPLACE with:

    if (FALSE)
    {
      $wheres[] = "MATCH name AGAINST ('".database_safe($q)."')";
    }
    else
    {
      $wheres[] = "name LIKE '%".database_safe($q)."%'";
    }

It's no problem to replace accented characters with their ASCII equivalent in the URL - see this comment for a nice method using iconv()...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by smartprice24 on Thu, 2018-01-11 11:51

Hi David. Many Thanks for support and your time.

The error is solved. However, I do not see the classic product information.

I visualize, a row equal to the row of the search results, with the product in question and immediately the footer of the site.

Basically: do not display the products.php, price.php etc.

Thanks David.

Submitted by smartprice24 on Thu, 2018-01-11 12:12

Hi David.

After re-importing the products, i solved the problem.

I do not know how, but now it works well.

Thank you so much for your assistance.

Good day.

Giuseppe