We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24160
    • 15 Posts
    I am currently use modx 0.9.6 Just updated to ajaxsearch to 1.7. when I perform a search
    It said, "database_connection_charset is null. Check your config file"

    My ajaxsearch call is [!AjaxSearch? ajaxSearch=`1` &AS_showResults=`1` &AS_landing=`8` &showMoreResults=`1` &moreResultsPage=`8` &extract=`0` &addJscript=`1` &ajaxSearchType=`1` &showMoreResult=`1` &ajaxMax=`5` !]

    Why would that happen?
      • 5811
      • 1,717 Posts
      Hi qm777,

      I am still writing the wiki documentation (coming soon) grin. Here is the extract regarding the errors messages of the version 1.7:

      ==Error messages==

      AjaxSearch version is not defined. Please check the snippet code in MODx manager.
      means that the snippet code in the manager is not properly installed or has changed and doesn’t fit with the snippet source folder (includes/snippet.ajaxSearch.inc.php)

      AjaxSearch version is obsolete. Please check the snippet code in MODx manager.
      means that you the version of the snippet code in the manager doesn’t fit with the version of the snippet source folder (includes/snippet.ajaxSearch.inc.php)

      AjaxSearch setup path is not defined. Please check the snippet code in MODx manager.
      means that the snippet code in the manager is not properly installed or has changed and doesn’t fit with the snippet source folder (includes/snippet.ajaxSearch.inc.php)

      AjaxSearch version obsolete. Check the version of AjaxSearch.js file
      means that your version of the snippet source folder (includes/snippet.ajaxSearch.inc.php) doesn’t fit with the js/ajaxSearch.js file

      AjaxSearch: database_connection_charset not set. Check your config file
      means that your $database_connection_charset variable of your /manager/includes/config.inc.php file should be set

      AjaxSearch: database_connection_charset is null. Check your config file
      means that your $database_connection_charset variable of your /manager/includes/config.inc.php file is an empty value

      AjaxSearch: unknown database_connection_charset = something. Add the appropriate Html charset mapping in the ajaxSearch.php file
      is not an error but need that you add in the ajaxSearch.php file the mapping between the mysql database charset and the html charset. e.g: ’latin1’ => ’ISO-8859-1’,


      Tell me if these explanations are insufficient or inadequate.
        • 28042 ☆ A M B ☆
        • 24,524 Posts
        The latest versions of MODx specify the connect charset of your database and AjaxSearch now uses that. It solves a lot of problems with searching text with various non-Western characters. You’ll need to add a line to your config.inc.php file if it’s not already there:
        $database_connection_charset = '';

        and put the proper connection for your database.

        The user comments on this page have a great deal of interesting material on this subject.

        http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html
        http://dev.mysql.com/doc/refman/5.0/en/charset-charsets.html
          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
          • 13428 ☆ A M B ☆
          • 1,031 Posts
          WARNING: After setting the database_connection_charset to utf8 on an installation without an database_connection_charset everything in the backend retrieved from the database could show utf8-decoded chars for utf8-encoded chars before. Maybe it will happen only on installations with TinyMCE set to ’raw’. It could be solved i.e. by export/patch/import the data via phpMyAdmin.

            • 24160
            • 15 Posts
            Thanks for that, nice grin
              • 1531
              • 42 Posts
              Have a problem with this right now. Whar Charset to use? utf8_general_ci was unknown (got it from phpmyadmin). Is it just utf8 then?
                The man, the myth
                • 5811
                • 1,717 Posts
                utf8_general_ci is the charset collation. utf8 the charset.

                So, if the charset of your database is utf8, put ’utf8’ as value for the $database_connection_charset variable inside the /manager/includes/config.inc.php file.
                $database_connection_charset = 'utf8';
                  • 1531
                  • 42 Posts
                  It doesnt work couse it mess up my swedish characters åäö/ÅÄÖ

                  (Or in some places anyway like some names in the document menu)
                    The man, the myth
                    • 7231
                    • 4,205 Posts
                    If you change the charset of an existing database the special characters will be broken. I have found that sometimes you can fix this by exporting as a new charset from some versions of phpmyadmin and then re importing as the new charset. However this does not work for all field types, it seems to only work on text fields and not in varchar fields so stuff like page titles and long titles will need to be re entered. You can also try a code editor and do find/replace to the sql file, this can work but is scetchy (make sure to have a back up just in case).
                      [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                      Something is happening here, but you don't know what it is.
                      Do you, Mr. Jones? - [bob dylan]
                      • 13428 ☆ A M B ☆
                      • 1,031 Posts
                      Just to remember: He did not change the database-charset itself. He changed the database-connection-charset of MODx to the database. This causes the problems with the unicode chars in his installation (same for me at two different german ISP).

                      This behaviour could be a bigger issue for upgrading unicode-MODx installations when AS 1.7+ will be standard in next versions of MODx.

                      My solution is to export my database (by phpMyAdmin) to sql-text, search & replace the wrong coded chars and reimport the sql-text in the database.