Please attach the page instead of copy/paste... I want to open it with Dreamweaver.
Try adding this after the $UpdateQuery->->execute() on line 191:
var_dump($UpdateQuery);
die();
That could give more information about why it is failing. There are no obvious problems I can see.