Hrm
It might be your $forumids = array(1,2,3,4,5,6,7,); line. Try taking out the last , in that.
What I found handy when developing the hack was doing this:
Code:
if ($bbuserinfo[userid] == 1) {
echo "<pre>".print_r($thread, true)."</pre>";
}
Replace 1 with your userid. What this will do is *just* for you, print out ALL the information it's got in your browser window. You can then see what the values are for the $thread[attachmentid] etc
Obviously turn it off before you go live