By far the biggest single problem that crops up again and again with Associate-O-Matic users is the dreaded XML Parser error. To the user, it seems to appear out of nowhere; there you are, working away on your site, when suddenly the error pops up. If you try to save your work, then the most horrible thing happens – It erases your site! All your changes and customizations are gone in a flash. Why does this happen?
The first thing you need to know about the XML Parser is that it’s not something built into AOM itself. It’s actually a PHP function. PHP is a programming language, like BASIC, Perl, Ajax, CGI, etc. And like any computer language, it’s very exact. Anyone who’s ever spent a few hours searching through code to find a misplaced or missing ‘ will know what I mean. As such, the Parser is designed to protect PHP by throwing up an error message whenever it encounters something it can’t process. Overriding the error (by saving your control panel settings) will create something akin to a paradox in the server. It compensates for this by blanking out the offending code. Unfortunately, this is your cfg.saved.php file, where all your control panel settings are kept. I’m oversimplifying the process, but the details aren’t important, just the results.
And what gives PHP such fits? Usually it’s nonstandard, nonalphanumeric characters or symbols. The most common ones are things like bullets (?) or the copyright notice (©). Altho it can also be things like letters with accents (é, ü, ñ, î), or the famous “not an apostrophe” apostrophe (´). This last one is usually found when text is cut and pasted from a source that did not use the more common “genuine” apostrophe (‘). They may look the same or similar to you, but not to the parser.
If you get one of these errors, what should you do? The most important thing to do is to not try to save your control panel. You may end up deleting all your saved settings. Instead, open another window, or fire up your FTP program, and backup a copy of the cfg.saved.php file to your hard drive. Then at least you have a copy of your settings.
Once that’s done, open the file in a text editing program like Notepad or Wordpad. I’m fond of using Notepad ++ (which can be downloaded off the net for free). It is an enhanced version of Notepad that gives you line numbers. The message you get from the parser will tell you what line the error starts at, so it’s easy to zoom in on where the problem lies. It may not exactly match, since the Parser and Notepad ++ seem to differ on how they count lines. But it will get you in the ballpark.
Scan carefully through the lines in this area and look for anything that may not be a standard alphanumeric character, as shown a few paragraphs above. Once you find it (and there may be more than one), remove it and save the file. You can then go back to your open control panel window and see if you can find the character/symbol that way. If you do, remove it and save.
With luck, the error message will go away. If not, keep looking. And if saving the file erases your settings, you’ve still got the copy you just backed up onto your computer. You can restore the file and try again to locate the problem.
Okay, you might be saying; you get an error, find the symbol causing it, and remove it. Now what? does this mean you can’t use bullets or symbols in your custom pages/boxes? No, of course not. But you need to use the character code instead of the actual symbol. The code is an acceptable way to tell the browser to display a certain character without actually using the character. If you remember the old days of ASCII codes for characters, then you’re aware of what I’m saying. The W3C page displaying the codes is available here. It shows you that things like the copyright symbol can be displayed by using & # 1 6 9 ; instead of ©. Note that you don’t use the spaces between the characters as I’m showing here. If I remove them, all you’ll see will be another copyright symbol. I could also say ampersand then hash mark then 169 then a semi-colon.
Some characters also have a shorthand code; the copyright symbol would be & copy ; (again, without the spaces). Just look up HTML Character set on Google, and you’ll find many sites with one or both versions of the codes used. The bottom line is that you can use the codes instead of the actual characters to achieve the same result. And the Parser will be a happy camper.
End notes: If your site suddenly displays an XML Parser error, and you haven’t made any changes to your AOM site, it’s often the result of an PHP upgrade by your host. This may change the sensitivity of the parser to certain characters that it was okay with before.
The newest version of AOM (V4.1.4) now includes automatic backups of your cfg.saved.php file, which will hopefully reduce the chance of losing all your data in case the Parser does eat your file. Simply select manage backups from the top of the control panel. You will then see a list of backups you can select to delete or restore. Having a copy on your hard drive is still a good idea, in case your host has a major data loss (I had a host that suffered a fire in their datacenter; all the hardware was toasted, literally).