We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 47430
    • 23 Posts
    My sites (a main site with 7 subsites) are almost done. But I found some error from the log. It seemed there was a wrong sql issued somewhere from a snippet (or maybe some part of the core?) .
    But the sites seemed no problems ( or I have not found just for now ).
    The log:

    [2014-12-21 23:35:12] (ERROR @ /index.php) Error 42000 executing statement:
    Array
    (
    [0] => 42000
    [1] => 1064
    [2] => 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 ') AND (modResource.context_key IN ('consfolk') OR EXISTS(SELECT 1 FROM `yntc_con' at line 1
    )

    [2014-12-21 23:35:12] (ERROR @ /index.php) Error 42000 executing statement:
    Array
    (
    [0] => 42000
    [1] => 1064
    [2] => 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 ') AND (modResource.context_key IN ('mechelec') OR EXISTS(SELECT 1 FROM `yntc_con' at line 1
    )

    [2014-12-21 23:35:12] (ERROR @ /index.php) Error 42000 executing statement:
    Array
    (
    [0] => 42000
    [1] => 1064
    [2] => 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 ') AND (modResource.context_key IN ('chembiol') OR EXISTS(SELECT 1 FROM `yntc_con' at line 1
    )

    [2014-12-21 23:35:12] (ERROR @ /index.php) Error 42000 executing statement:
    Array
    (
    [0] => 42000
    [1] => 1064
    [2] => 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 ') AND (modResource.context_key IN ('baseteac') OR EXISTS(SELECT 1 FROM `yntc_con' at line 1
    )

    [2014-12-21 23:35:12] (ERROR @ /index.php) Error 42000 executing statement:
    Array
    (
    [0] => 42000
    [1] => 1064
    [2] => 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 ') AND (modResource.context_key IN ('luxi') OR EXISTS(SELECT 1 FROM `yntc_context' at line 1
    )

    Any idea?
    Thanks in advance.
      • 3749
      • 24,544 Posts
      I don't think it's the core. One table it's referencing is not a MODX table (yntc_con). yntc_context could be a MODX table if your prefix is 'yntc_'. These are also not MODX terms: 'luxi', 'baseteac', 'chembiol'.

      My guess would be an extra that doesn't work with the version of MODX you're running.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        Those are contexts, so it kind of looks like some kind of context switcher. A plugin, maybe? or some kind of logging tool?
          Studying MODX in the desert - http://sottwell.com
          Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
          Join the Slack Community - http://modx.org
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          What version is your MySQL server (not the client)?
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 47430
            • 23 Posts
            Thank you all for reply.

            Yes, I have those contexts, like itec, luxi, consfolk, baseteac, chembiol, etc...
            I wrote the contexts switcher myself. The code is:

            <?php
            if ( $modx->context->get('key') != 'mgr' ){
            switch($_REQUEST['dept']){
            case 'itec':
            $modx->switchContext('itec');
            break;
            case 'consfolk':
            $modx->switchContext('consfolk');
            break;
            case 'mechelec':
            $modx->switchContext('mechelec');
            break;
            case 'chembiol':
            $modx->switchContext('chembiol');
            break;
            case 'baseteac':
            $modx->switchContext('baseteac');
            break;
            case 'luxi':
            $modx->switchContext('luxi');
            break;
            case 'cultlife':
            $modx->switchContext('cultlife');
            break;
            default:
            $modx->switchContext('web');
            break;
            }
            unset($_GET['dept']);
            }

            The code seemed function well.

            MySQL Server is: ver 14.14 Distrib 5.1.73, it's running on CentOS 6.5 .

            If it is like what Bob said, how can I figure out which plugin is issuing the wrong sql?

            Thank you!
              • 3749
              • 24,544 Posts
              Is there a table in your DB called 'yntc_con'? That's what the query is looking for in the first four error messages.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                Bob, that's only part of the table name, it gets chopped off in the error message. The last one has yntc_context before it gets chopped off. Is the table_prefix of your modx installation yntc, instead of modx_? What, exactly, is the name of that table, and what extra is using it?
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                  • 47430
                  • 23 Posts
                  Sottwell is right, the table name is yntc_context, and yntc_ is my table prefix. The extras I'm using: getResources, Wayfinder, Hits, advSearch, NewsPublisher, BreadCrump, Collections, phpThumbOf, RezImgCrop ...

                  What I want to know is -- is there a way I can figure out which sippet issued the wrong SQL?
                  (Why the table name has been chopped? it may be a clue...)

                  Thanks.
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    That's just PHP's presentation of the error, it only shows so many characters of the offending code and chops it off where it pleases.

                    One way, if you have access to the server is to do a search on the files for that offending string.

                    grep -rnw 'www' -e "OR EXISTS(SELECT 1 FROM"


                    That should be specific enough to locate the offending code. The entire string won't work, since the code will have variables in some places. But that string doesn't appear in any of my localhost installations, so it's probably pretty specific to whatver snippet or plugin is causing the problem.
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      Well, well. It turns out to be in getResources.

                      /home/www/core/packages/getresources-1.5.1-pl/preserved.php:225:    $criteria[] = "(modResource.context_key IN ({$context}) OR EXISTS(SELECT 1 FROM {$contextResourceTbl} ctx WHERE ctx.resource = modResource.id AND ctx.context_key IN ({$context})))";
                        Studying MODX in the desert - http://sottwell.com
                        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                        Join the Slack Community - http://modx.org