We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15155
    • 11 Posts
    I am using version 5. Tried your snippet and got this error:

    « MODx Parse Error »
    MODx encountered the following error while attempting to parse the requested resource:
    « Execution of a query to the database failed - 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 ’-name FROM `modx_site_content` sc LEFT JOIN( SELECT DISTINCT tv1.contentid , tv1’ at line 1 »
    SQL: SELECT sc.id, sc.pagetitle, sc.longtitle, sc.description, sc.alias, sc.introtext, sc.template, sc.menutitle, sc.content, sc.publishedon, ntv1.value AS business-name FROM `modx_site_content` sc LEFT JOIN( SELECT DISTINCT tv1.contentid , tv1.value FROM `modx_site_tmplvar_contentvalues` tv1 WHERE tv1.tmplvarid = ’18’ ) AS ntv1 ON sc.id = ntv1.contentid WHERE ((sc.id IN (46,48,49,50,47,45,26,25,44,43,41,40,39,38,42,36,28,29,30,31,32,33,34,35,37)) AND (sc.published=1) AND (sc.searchable=1) AND (sc.deleted=0) AND (sc.privateweb=0)) GROUP BY sc.id HAVING (((sc.pagetitle REGEXP ’[[:<:]]express[[:>:]]’) OR (sc.longtitle REGEXP ’[[:<:]]express[[:>:]]’) OR (sc.description REGEXP ’[[:<:]]express[[:>:]]’) OR (sc.alias REGEXP ’[[:<:]]express[[:>:]]’) OR (sc.introtext REGEXP ’[[:<:]]express[[:>:]]’) OR (sc.menutitle REGEXP ’[[:<:]]express[[:>:]]’) OR (sc.content REGEXP ’[[:<:]]express[[:>:]]’) OR (business-name REGEXP ’[[:<:]]express[[:>:]]’))) ORDER BY sc.publishedon,sc.pagetitl

      • 5811
      • 1,717 Posts
      You are right, this is a bug. It comes from the fact I forgot to frame the tv name with quotes. And As your TV name is business-name, it causes a mysql error.

      This should be:
      SELECT sc.id, sc.pagetitle, sc.longtitle, sc.description, sc.alias, sc.introtext, sc.template, sc.menutitle, sc.content, sc.publishedon, ntv1.value AS `business-name` FROM `modx_site_content` sc LEFT JOIN( SELECT DISTINCT tv1.contentid , tv1.value FROM `modx_site_tmplvar_contentvalues` tv1 WHERE tv1.tmplvarid = ’18’ ) AS ntv1 ON sc.id = ntv1.contentid WHERE ((sc.id IN (46,48,49,50,47,45,26,25,44,43,41,40,39,38,42,36,28,29,30,31,32,33,34,35,37)) AND (sc.published=1) AND (sc.searchable=1) AND (sc.deleted=0) AND (sc.privateweb=0)) GROUP BY sc.id HAVING (((sc.pagetitle REGEXP ’[[:<:]]express[[:>:]]’) OR (sc.longtitle REGEXP ’[[:<:]]express[[:>:]]’) OR (sc.description REGEXP ’[[:<:]]express[[:>:]]’) OR (sc.alias REGEXP ’[[:<:]]express[[:>:]]’) OR (sc.introtext REGEXP ’[[:<:]]express[[:>:]]’) OR (sc.menutitle REGEXP ’[[:<:]]express[[:>:]]’) OR (sc.content REGEXP ’[[:<:]]express[[:>:]]’) OR (`business-name` REGEXP ’[[:<:]]express[[:>:]]’))) ORDER BY sc.publishedon,sc.pagetitle

      Until to get the patch which solve this issue, may be you could rename your tv "business-name" as "business_name".
        • 15155
        • 11 Posts
        Thanks coroico! Do you accept donations via PayPal? I have another question. How can I exclude some TV values from being displayed in the search results?

        This is the snippet call
        [! AjaxSearch? &ajaxSearch=`0` &showInputForm=`0` &pagingType=`0` &parents=`in:24` &advSearch=`exactphrase` &withTvs=`-:color` !]



        And I’m getting another massive error

        MODx encountered the following error while attempting to parse the requested resource:
        « Execution of a query to the database failed - 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 ’-panel-main, ntv2.value AS industry-panel-main, ntv3.value AS government-panel-m’ at line 1 »
        SQL: SELECT sc.id, sc.pagetitle, sc.longtitle, sc.description, sc.alias, sc.introtext, sc.template, sc.menutitle, sc.content, sc.publishedon, GROUP_CONCAT( DISTINCT CAST(ntv.id AS CHAR) SEPARATOR "," ) AS tv_id, GROUP_CONCAT( DISTINCT ntv.value SEPARATOR "," ) AS tv_value, ntv1.value AS client-panel-main, ntv2.value AS industry-panel-main, ntv3.value AS government-panel-main, ntv4.value AS page-header, ntv5.value AS company-name, ntv6.value AS fax, ntv7.value AS website, ntv8.value AS bbb-rating, ntv9.value AS psc-member, ntv10.value AS business_name, ntv11.value AS start-date, ntv12.value AS principal, ntv13.value AS customer-contact, ntv14.value AS incorporated, ntv15.value AS bbb-accreditation, ntv16.value AS phone, ntv17.value AS email-address, ntv18.value AS keywords, ntv19.value AS description FROM `modx_site_content` sc LEFT JOIN( SELECT DISTINCT tv.id, tv.value, tv.contentid FROM `modx_site_tmplvar_contentvalues` tv ) AS ntv ON sc.id = ntv.contentid LEFT JOIN( SELECT DISTINCT tv1.contentid , tv1.value FROM `modx_site_tmplvar_contentvalues` tv1 WHERE tv1.tmplvarid = ’1’ ) AS ntv1 ON sc.id = ntv1.contentid LEFT JOIN( SELECT DISTINCT tv2.contentid , tv2.value FROM `modx_site_tmplvar_contentvalues` tv2 WHERE tv2.tmplvarid = ’3’ ) AS ntv2 ON sc.id = ntv2.contentid LEFT JOIN( SELECT DISTINCT tv3.contentid , tv3.value FROM `modx_site_tmplvar_contentvalues` tv3 WHERE tv3.tmplvarid = ’2’ ) AS ntv3 ON sc.id = ntv3.contentid LEFT JOIN( SELECT DISTINCT tv4.contentid , tv4.value FROM `modx_site_tmplvar_contentvalues` tv4 WHERE tv4.tmplvarid = ’5’ ) AS ntv4 ON sc.id = ntv4.contentid LEFT JOIN( SELECT DISTINCT tv5.contentid , tv5.value FROM `modx_site_tmplvar_contentvalues` tv5 WHERE tv5.tmplvarid = ’8’ ) AS ntv5 ON sc.id = ntv5.contentid LEFT JOIN( SELECT DISTINCT tv6.contentid , tv6.value FROM `modx_site_tmplvar_contentvalues` tv6 WHERE tv6.tmplvarid = ’27’ ) AS ntv6 ON sc.id = ntv6.contentid LEFT JOIN( SELECT DISTINCT tv7.contentid , tv7.value FROM `modx_site_tmplvar_contentvalues` tv7 WHERE tv7.tmplvarid = ’28’ ) AS ntv7 ON sc.id = ntv7.contentid LEFT JOIN( SELECT DISTINCT tv8.contentid , tv8.value FROM `modx_site_tmplvar_contentvalues` tv8 WHERE tv8.tmplvarid = ’11’ ) AS ntv8 ON sc.id = ntv8.contentid LEFT JOIN( SELECT DISTINCT tv9.contentid , tv9.value FROM `modx_site_tmplvar_contentvalues` tv9 WHERE tv9.tmplvarid = ’12’ ) AS ntv9 ON sc.id = ntv9.contentid LEFT JOIN( SELECT DISTINCT tv10.contentid , tv10.value FROM `modx_site_tmplvar_contentvalues` tv10 WHERE tv10.tmplvarid = ’18’ ) AS ntv10 ON sc.id = ntv10.contentid LEFT JOIN( SELECT DISTINCT tv11.contentid , tv11.value FROM `modx_site_tmplvar_contentvalues` tv11 WHERE tv11.tmplvarid = ’20’ ) AS ntv11 ON sc.id = ntv11.contentid LEFT JOIN( SELECT DISTINCT tv12.contentid , tv12.value FROM `modx_site_tmplvar_contentvalues` tv12 WHERE tv12.tmplvarid = ’21’ ) AS ntv12 ON sc.id = ntv12.contentid LEFT JOIN( SELECT DISTINCT tv13.contentid , tv13.value FROM `modx_site_tmplvar_contentvalues` tv13 WHERE tv13.tmplvarid = ’22’ ) AS ntv13 ON sc.id = ntv13.contentid LEFT JOIN( SELECT DISTINCT tv14.contentid , tv14.value FROM `modx_site_tmplvar_contentvalues` tv14 WHERE tv14.tmplvarid = ’23’ ) AS ntv14 ON sc.id = ntv14.contentid LEFT JOIN( SELECT DISTINCT tv15.contentid , tv15.value FROM `modx_site_tmplvar_contentvalues` tv15 WHERE tv15.tmplvarid = ’25’ ) AS ntv15 ON sc.id = ntv15.contentid LEFT JOIN( SELECT DISTINCT tv16.contentid , tv16.value FROM `modx_site_tmplvar_contentvalues` tv16 WHERE tv16.tmplvarid = ’29’ ) AS ntv16 ON sc.id = ntv16.contentid LEFT JOIN( SELECT DISTINCT tv17.contentid , tv17.value FROM `modx_site_tmplvar_contentvalues` tv17 WHERE tv17.tmplvarid = ’30’ ) AS ntv17 ON sc.id = ntv17.contentid LEFT JOIN( SELECT DISTINCT tv18.contentid , tv18.value FROM `modx_site_tmplvar_contentvalues` tv18 WHERE tv18.tmplvarid = ’31’ ) AS ntv18 ON sc.id = ntv18.contentid LEFT JOIN( SELECT DISTINCT tv19.contentid , tv19.value FROM `modx_site_tmplvar_contentvalues` tv19 WHERE tv19.tmplvarid = ’32’ ) AS ntv19 ON sc.id = ntv19.contentid WHERE ((sc.id IN (46,48,49,50,47,45,26,25,44,43,41,40,39,38,42,36,28,29,30,31,32,33,34,35,37)) AND (sc.published=1) AND (sc.searchable=1) AND (sc.deleted=0) AND (sc.privateweb=0)) GROUP BY sc.id HAVING (((sc.pagetitle REGEXP ’[[:<:]]express[[:>:]]’) OR (sc.longtitle REGEXP ’[[:<:]]express[[:>:]]’) OR (sc.description REGEXP ’[[:<:]]express[[:>:]]’) OR (sc.alias REGEXP ’[[:<:]]express[[:>:]]’) OR (sc.introtext REGEXP ’[[:<:]]express[[:>:]]’) OR (sc.menutitle REGEXP ’[[:<:]]express[[:>:]]’) OR (sc.content REGEXP ’[[:<:]]express[[:>:]]’) OR (tv_value REGEXP ’[[:<:]]express[[:>:]]’) OR (client-panel-main REGEXP ’[[:<:]]express[[:>:]]’) OR (industry-panel-main REGEXP ’[[:<:]]express[[:>:]]’) OR (government-panel-main REGEXP ’[[:<:]]express[[:>:]]’) OR (page-header REGEXP ’[[:<:]]express[[:>:]]’) OR (company-name REGEXP ’[[:<:]]express[[:>:]]’) OR (fax REGEXP ’[[:<:]]express[[:>:]]’) OR (website REGEXP ’[[:<:]]express[[:>:]]’) OR (bbb-rating REGEXP ’[[:<:]]express[[:>:]]’) OR (psc-member REGEXP ’[[:<:]]express[[:>:]]’) OR (business_name REGEXP ’[[:<:]]express[[:>:]]’) OR (start-date REGEXP ’[[:<:]]express[[:>:]]’) OR (principal REGEXP ’[[:<:]]express[[:>:]]’) OR (customer-contact REGEXP ’[[:<:]]express[[:>:]]’) OR (incorporated REGEXP ’[[:<:]]express[[:>:]]’) OR (bbb-accreditation REGEXP ’[[:<:]]express[[:>:]]’) OR (phone REGEXP ’[[:<:]]express[[:>:]]’) OR (email-address REGEXP ’[[:<:]]express[[:>:]]’) OR (keyexpresss REGEXP ’[[:<:]]express[[:>:]]’) OR (description REGEXP ’[[:<:]]express[[:>:]]’))) ORDER BY sc.publishedon,sc.pagetitle
          • 5811
          • 1,717 Posts
          Do you accept donations via PayPal?
          Yes donation are accepted from this page (or thru the Donate button under the left menu). Thanks

          And I’m getting another massive error.
          Because lot of tv names include a ’-’ sign.
          So, rather to change the names of all your Tvs, find enclosed a patch to correct the issue. Remove the txt extension of the file and drop it in the ajaxSearch/classes/ folder.
          This patch will be included in the next release of ajaxSearch.
          [EDIT] Issue registered as AJAXSEARCH#76 : TV names not protected in sql request.


          In any case it is better to use &withTvs=`+:tv1,tv2,tv3, ...` rather than &withTvs=`-:color`. Because as explained here this could generate a rich sql statement.
            • 27930
            • 23 Posts
            My AjaxSearch is not showing results in landing page if I turn friendly urls on and search from url like www.domain.com/url1/url2. If I start searching from the home page it redirects me to the landing page normally.
            Without friendly urls AS is working perfectly, too. I do have the <base> tag in the head of the template.

            Here are the snippet calls:

            [!AjaxSearch? 
              &ajaxSearch=`0` 
              &showResults=`0`
              &landingPage=`132`
            !]


            and the landing page:

            [!AjaxSearch? &ajaxSearch=`0` &showInputForm=`0`!]


            Please, help. where is my error?