I don't think this is an issue with the pages you have attached. Maybe an issue with the item added itself, or maybe something to do with having magicQuotesGPC enabled and having a quote in the product name?
One way to debug is to comment out lines 477 and 478 where the errors occur and add this line in its place:
echo("\$nextItem =".$toExec.");");
Then add this a few lines later before the "return $retArray;" line:
die();
Then when you go to the page that was giving the error it would write the code to the page that was causing the error. If I looked at that I'd be able to be more confident in my diagnosis.
Without seeing that my best guess is that you have magicquotesgpc enabled and have a quotation mark in your product name.