Okay, on lines 53-57, you have this:
PHP Code:
$dl = $DB_site->query_first("SELECT downloads FROM user WHERE userid = $bbuserinfo[userid]");
$comma = ($dl[downloads]) ? ',' : '';
$DB_site->query("UPDATE user SET downloads = '$dl[downloads]$comma$attachmentid' WHERE userid = $bbuserinfo[userid]");
$comma = ($dl[downloads]) ? ',' : '';
$DB_site->query("UPDATE user SET downloads = '$dl[downloads]$comma$attachmentid' WHERE userid = $bbuserinfo[userid]");
REPLACE that with this:
PHP Code:
$dl = $DB_site->query_first("SELECT downloads FROM user WHERE userid = $bbuserinfo[userid]");
$comma = ($dl[downloads]) ? ',' : '';
$DB_site->query("UPDATE user SET downloads = '$dl[downloads]$comma$attachmentid' WHERE userid = $bbuserinfo[userid]");
I think that should work. Worth a try.