We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51862
    • 13 Posts


    Hi guys,

    Whenever I try to do anything code related, I get this popup (very briefly, I had to screenflow it to properly read it). I've kind of read some stuff about a similar error on the forums, but never specific to my situation. My web hosting says they can't help me with code related issues.

    Has anyone seen this before? I tried clearing my cache and adding a .htaccess file in the resources folder, sadly without results.

    Thanks in advance!
      • 3749
      • 24,544 Posts
      The "unexpected token" usually means something in a MODX processor is throwing a fatal PHP error, which makes the processor return the error message instead of what it's supposed to.

      You can sometimes look at the Network tabs in FF or Chrome Dev. tools (ctrl-shift-i) and drill down to the response to to see the actual error.

      Since it's a 403, it may be caused by the host's mod_security settings. Who is your host?
        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
        Is this when saving the .css file, or when opening 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
          • 51862
          • 13 Posts
          Quote from: BobRay at Mar 15, 2016, 01:45 PM
          The "unexpected token" usually means something in a MODX processor is throwing a fatal PHP error, which makes the processor return the error message instead of what it's supposed to.

          You can sometimes look at the Network tabs in FF or Chrome Dev. tools (ctrl-shift-i) and drill down to the response to to see the actual error.

          Since it's a 403, it may be caused by the host's mod_security settings. Who is your host?
          I've narrowed the problem down a little. I don't think it's mod_security because it only occurs when I'm trying to use <style> tags in my html, or make updates in my css through the editor. No problems when I import a css file. My host is hostnet.nl, and they say I can't bypass the mod_security because I'm hosting from a shared server.

          Quote from: sottwell at Mar 15, 2016, 02:06 PM
          Is this when saving the .css file, or when opening it?
          It's when saving the css file. I can upload them without any problems. I've been deleting and reuploading my css files now, which of course isn't really convenient.

          Thanks, guys!
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            You need an FTP client that automatically loads a file into your editor of choice, and uploads it back on save. I use Cyberduck.

            Of course, that doesn't explain where the problem is coming from. It sounds like it's ether a mod_security issue, or a bad file in the MODX installation.

            They can disable or modify the configuration of mod_security for your domain if they want to.
              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
              • 51862
              • 13 Posts
              Seems like this workaround will have to do. My hosting service claims they can't modify the configuration, sadly.

              Thank you!
                • 3749
                • 24,544 Posts
                I does sound like mod_security to me. Maybe someone typed "style" when they meant to type "script" while setting up the rules or set up a rule for <s*.

                For future reference: http://bobsguides.com/modx-friendly-hosts.html

                  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