Troubleshooting error #2001

[h=1][FONT=arial][SIZE=3]Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs[/SIZE][/FONT][/h]
I run into this problem frequently when handling MySQL queries inside of Flash. I can usually figure out the problem, but the amount of time it takes is incredible sometimes. Part of the problem is that I have a hard time pinpointing where the problem is. The reason for that is that as far as I know, there is no way to see the String being passed that is causing the problem. First, is there a way to see this String, and second, if not, how do you typically troubleshoot this error?

For more details:

Normally, I am sending data via POST to a PHP script which runs a MySQL query and returns the results. For simplicity and ease of use on my end, I got in the habit of forming the queries in ActionScript and sending the query as a variable to the PHP script, so all the PHP script does is run it (I know its not the best practice). There are a number of reasons for getting the 2001 error. For instance this morning I encountered a 406 : Not Acceptable error every time I sent a query over POST that included a WHERE statement in it. SELECT * FROM table was fine. SELECT * FROM table WHERE userName=something was not (As a side note, I am still puzzled by this as in a different swf on the same server in a different folder, it is running the exact same queries in the exact same method using the exact same PHP code (in a different file) just fine. For now, I’ll just stick with the probably better practice of forming the queries in the PHP rather than in the ActionScript). It was difficult to figure out even what the error was on the server since when I navigateToURL() instead of URLLoader.load() all the POST data gets sent as GET and its hard to piece apart if the problem has something to do with the fact that PHP isn’t accessing the variable anymore or something else like a security restriction from certain queries to prevent cross-site scripting (which I assume was happening this time).