$extra was not being (re)initialized at the start of each iteration, so once it was set it would remain set in all following iterations. This would cause those queries to fail because of missing parameters. Fix by (re)setting $extra to empty at the start of each iteration.
$extra was not being (re)initialized at the start of each iteration, so once it was set it would remain set in all following iterations. This would cause those queries to fail because of missing parameters. Fix by (re)setting $extra to empty at the start of each iteration.