We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 727
    • 502 Posts
    Create a new document
    Save it
    Edit it
    Enter the following for the content:

    A person's name


    Save and you get a MySQL error because the apostrophe is not escaped:

    « 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 's name. ',richtext='1',template='10',menuindex='1',searchable='1',cacheable='1'' at line 1 »
          SQL: UPDATE `testcom`.`modx_site_content` SET id='72',type='document',contentType='text/html',pagetitle='A',longtitle='',description='',alias='a',link_attributes='',published='1',pub_date='0',unpub_date='0',parent='8',isfolder='0',introtext='',content='A person's name. ',richtext='1',template='10',menuindex='1',searchable='1',cacheable='1',createdby='1',createdon='1197175442',editedby='1',editedon='1197219728',deleted='0',deletedon='0',deletedby='0',publishedon='1197175442',publishedby='1',menutitle='',donthit='0',haskeywords='0',hasmetatags='0',privateweb='0',privatemgr='0',content_dispo='0',hidemenu='1' WHERE id=72 


    I searched the forums and didn’t find anyone else with this problem. Surely I’m not the only one who uses apostrophes?? Any ideas on how I can fix this quickly?

    Andy
    • I can’t duplicate this Andy...
        Ryan Thrash, MODX Co-Founder
        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
        • 727
        • 502 Posts
        I’m using UTF8 for everything. Might that be it?

        Andy
          • 727
          • 502 Posts
          OK, so more info. I have 0.9.6 and 0.9.6.1 running on the same webserver with the same MySQL server. Using the exact same PC (WinXP SP2) and browser (Firefox 1.5.0.12) I did the following:

          Log in to 0.9.6
          Create page called Test and save
          Edit page
          Enter "A person’s name" and save

          This worked fine. So I logged out.

          Log in to 0.9.6.1
          Create a page called Test and save
          Edit page
          Enter "A person’s name" and save

          I received the MySQL error. So this is reproducable and the only thing that changed was the version of MODx.

          Update: both databases being used in this test are using the same charset (UTF-8 Unicode) and the same collation (utf8_unicode_ci).

          Anything else I can try? Do you want a log in to the manager on my dev server?

          Andy
          • My test where I just tried to duplicate is the same:

            MySQL charset: UTF-8 Unicode (utf8)
            MySQL connection collation: utf8_unicode_ci

            (MySQL version 5.0.22)
              Ryan Thrash, MODX Co-Founder
              Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • Strict mode? I’ve seen some posts around here that that causes problems...
                Ryan Thrash, MODX Co-Founder
                Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • 727
                • 502 Posts
                Strict mode? Do you mean XHTML or something else?

                I am using MySQL 5.0.32-Debian_7etch1.

                Andy
                • No, mysql can be set to its own "strict" mode that does cause some problems. But since you’re using the same server and the same database, I would think that’s not the problem.

                  Where do you enter "a person’s name"? In the content of the document?
                    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
                  • I can’t duplicate this either.

                    MySQL version 5.0.41
                      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
                      • 727
                      • 502 Posts
                      Yes, I enter "A person’s name" into the document content then click on save.

                      I’m using the same MySQL server but the two installations of MODx are using different databases. But the databases have the same character encoding and collation.

                      Andy