It's not liking that $r{$i} business. Try using this instead:
if ($_POST[a{$i}] != ${'r'.$i}) { //***LINE 52***
EDIT: Forgot to explain what I did! Heh.
Basically, in my change, you're creating a string inside the brackets, and telling PHP to look for a variable called that. In your code, you gave part of the variable name, then tried to have PHP evaluate some code that should be appended.
It probably doesn't make sense anywhere in my mind, but at any rate, I don't think you can specify part of a variable name, then have PHP evalulate code to add on to the variable name. That's why I had the 'r' inside the brackets, so that the $i is appended to 'r', therefore giving you the entire variable name.
Clear as mud, right?