The first thing you can try is to reset the auto_increment field to what it should be. First, you'd need to find the max id for the table. For example, the posts table.

select MAX(POST_ID) from ubbt_POSTS

That will come back with some number, say 12345. Add one to that number and use it in the following query:

ALTER TABLE ubbt_POSTS AUTO_INCREMENT=123456;

If that doesn't fix it then it might require altering the row to drop the auto_increment field and then readding it.

ALTER TABLE ubbt_POSTS CHANGE POST_ID POST_ID int(11) unsigned primary key

then:

ALTER TABLE ubbt_POSTS CHANGE POST_ID POST_ID int(11) unsigned auto_increment primary key



Even though the tables are already messed up, I'd recommend doing a backup before doing anything, just in case something happens and it makes it worse.