It's being caused by a bit of faulty logic. Look at the block that starts:
PHP Code:
if($credits != 0 && $vid_uid!=$uid) {
That, and the other two conditionals, create a situation where sometimes "paid" could be undefined. Quick fix: put the following in front of the above line:
The code is somewhat shaky in a couple of other places as well.