I would re-do the hack. Try it a few times. It's the only way to know that it's not your syntax. Make sure all of your statements end with a semicolon and all of the variables have either a $ or @ in front of it (% is not being used in the changes from what I can tell).
Also, take a look at the HTML and make sure no whitespace where it would screw things up.