It sounds like the users weren't cleaned up very well. Basically it's stating that the user already exists in the groups table. What you need to do in short order is get the max userid that exists right now and then purge everything in the groups table that is higher than that id.
select max(USER_ID) from ubbt_USERS
Grab the result and run the query below, replacing $result with what you got from the above query.
delete from ubbt_USER_GROUPS where USER_ID > '$result'