that shouldn't have fixed the problem, only written the sql to the screen for troubleshooting that is what the line:
echo($WA_Sql);
should have don, if it is now woking, i suspect the changes weren't properly uploading to the server behavior, you should remove the echo statement from the page to prevent the SQL from being written to the page.