Simple Machines Community Forum

SMF Support => SMF 1.1.x Support => Topic started by: ComposerRyan on October 22, 2006, 08:17:59 PM

Title: [SOLVED] Duplicate members...anyway to erase the extra membernames?
Post by: ComposerRyan on October 22, 2006, 08:17:59 PM
I had to merge all of my forums by converting SMF to phpbb, then merge them using the phpbb script and then converting them all back to SMF.

Well, the only problem that I see is that there are duplicate users.  So, for instance, when viewing the memberlist, my name "ComposerRyan" shows up 4 times.  This is the same for all the other users.  Is there anyway to delete the other duplicate names easily?

Most of them share the exact same e-mail address, post count, etc...they just have different forum IDs though.  What to do what to do...

Yikes.  :'(
Title: Re: Duplicate members...anyway to erase the extra membernames?
Post by: Oldiesmann on October 22, 2006, 08:51:28 PM
Try this...

<?php
include_once('SSI.php');

// Find the first instance of each username...
$query = db_query("SELECT ID_MEMBER, memberName FROM {$db_prefix}members", __FILE__, __LINE__);

// Delete the others...
while($results = mysql_fetch_assoc($query))
{
 
db_query("DELETE FROM {$db_prefix}members WHERE memberName = '$results[memberName]' AND ID_MEMBER != '$results[ID_MEMBER]'", __FILE__, __LINE__);
}
?>


Since MySQL will pull the results in ascending order by the member ID by default, that shouldn't cause any problems.
Title: Re: Duplicate members...anyway to erase the extra membernames?
Post by: ComposerRyan on October 22, 2006, 09:17:28 PM
Sorry, but I'm really dumb at this kind of stuff...where do I put this file???

I'll go ahead and make a backup now just in case while I wait for your response.  I appreciate your help. :)
Title: Re: Duplicate members...anyway to erase the extra membernames?
Post by: JayBachatero on October 22, 2006, 09:58:54 PM
Just name it deletemembers.php and upload it to your site.  Then point your browser to it.
Title: Re: Duplicate members...anyway to erase the extra membernames?
Post by: ComposerRyan on October 22, 2006, 10:40:39 PM
I ran the script, but it deleted ALL the duplicates...I wanted it to keep at least one of the member names. :(

So, for instance, instead of keeping ONE "ComposerRyan" username intact, it just deleted ALL of them and did the same for all my other users.

Is there anyway you can fix the script so that it ONLY deletes the duplicates and keeps the originals?  Or is that asking for too much?
Title: Re: Duplicate members...anyway to erase the extra membernames?
Post by: ComposerRyan on October 22, 2006, 11:11:17 PM
Nevermind, I just migrated my Joomla users back into SMF and it seems to be working.  The only problem is that member's profiles don't work in some cases, which is okay.  No big deal...they'll have to get over it. lol

Thanks for your help, I appreciate it!
Title: Re: [SOLVED] Duplicate members...anyway to erase the extra membernames?
Post by: JayBachatero on October 22, 2006, 11:12:37 PM
What do you mean they don't work?