Just a quick look reveals the following:
- You didn't close your parens in the last 3 lines of the first section
- You are referring to a single member of an array with the wrong variable
prefix (that is, it should be $filename[$i], don't use the @).
Other errors may be in there, but until you fix those, you're not going to get anywhere.
By the way, a list of errors encounters always helps.
-
HZ