MyBB Community Forums

Full Version: SQL 1062 Error duplicate Entry
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
Well, I am back, and surprise, surprise, with another error.
This happened at the import users stage

Quote:MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1062 - Duplicate entry '' for key 'username'
Query:
INSERT INTO mybb_users (usergroup,additionalgroups,displaygroup,import_usergroup,import_additionalgroups,import_displaygroup,import_uid,username,password,salt,loginkey,email,regdate,lastactive,lastvisit,website,showsigs,signature,showavatars,timezone,avatardimensions,avatartype,avatar,lastpost,icq,aim,yahoo,msn,hideemail,allownotices,regip,lastip,longregip,longlastip,language,passwordconvert,passwordconverttype,postnum,invisible,birthday,birthdayprivacy,subscriptionmethod,receivepms,receivefrombuddy,pmnotice,pmnotify,showquickreply,ppp,tpp,daysprune,timeformat,dst,buddylist,ignorelist,style,away,awaydate,returndate,referrer,referrals,reputation,timeonline,showcodebuttons,totalpms,unreadpms,pmfolders,notepad,threadmode,showredirect,dateformat,dstcorrection,warningpoints,moderateposts,moderationtime,suspendposting,suspensiontime,suspendsignature,suspendsigtime,coppauser,classicpostbit,loginattempts,failedlogin,usernotes) VALUES ('2,2','2','2,2','27,','7','7','55','','','f00bcb30049ba68d','GKvH6IRtwRpL2KYzJO4w2cKJrdvN3T8dEuGFkwFwkP4quJnEtC','[email protected]','1303682094','1303945956','1303945956','','1','','1','-80','0|0','','','1303945954','','','','','1','0','76.115.xxx.xxx','','0','0','','$H$9fO7wJ8qiFPWp.y.QDOphbbFuaQ1gF/','phpbb3','0','1','','all','0','1','0','1','1','1','0','0','0','D M d, Y g:i a','1','','','0','0','0','0','0','0','0','0','1','0','0','1**Inbox$%%$2**Sent Items$%%$3**Drafts$%%$4**Trash Can','','','1','0','1','0','0','0','0','0','0','0','0','0','0','0','')
Please contact the MyBB Group for support.


IP address and email are blotted out for security.
Take it this happens when you try to merge a user?

Anyway, this is caused by trying to add a user with a username that is already taken (as is obvious from the error).

What are you merging from exactly?
(2011-05-11, 02:48 PM)euantor Wrote: [ -> ]Take it this happens when you try to merge a user?

Anyway, this is caused by trying to add a user with a username that is already taken (as is obvious from the error).

What are you merging from exactly?

This happened when it was moving users (merge system second step). so, me as an Administrator should not be registered on the board yet? Because that was the only possible conflict.

Now, I have this error for one other user that is supposedly conflicting.
Quote:MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1062 - Duplicate entry '' for key 'username'
Query:
INSERT INTO mybb_users (usergroup,additionalgroups,displaygroup,import_usergroup,import_additionalgroups,import_displaygroup,import_uid,username,password,salt,loginkey,email,regdate,lastactive,lastvisit,website,showsigs,signature,showavatars,timezone,avatardimensions,avatartype,avatar,lastpost,icq,aim,yahoo,msn,hideemail,allownotices,regip,lastip,longregip,longlastip,language,passwordconvert,passwordconverttype,postnum,invisible,birthday,birthdayprivacy,subscriptionmethod,receivepms,receivefrombuddy,pmnotice,pmnotify,showquickreply,ppp,tpp,daysprune,timeformat,dst,buddylist,ignorelist,style,away,awaydate,returndate,referrer,referrals,reputation,timeonline,showcodebuttons,totalpms,unreadpms,pmfolders,notepad,threadmode,showredirect,dateformat,dstcorrection,warningpoints,moderateposts,moderationtime,suspendposting,suspensiontime,suspendsignature,suspendsigtime,coppauser,classicpostbit,loginattempts,failedlogin,usernotes) VALUES ('2,2','2','2,2','28,','8','8','54','','','459f9e04a98df494','zatdCCBZdlupFZo7BrFebHCQ75jFhTeUovx7ld2Z3vcNl9q24G','[email protected]','1303581412','1304993578','1304993578','','1','','1','-60','0|0','','','1304240403','','','','','1','0','71.213.227.211','','0','0','','$H$9PRUHQcsoCHwvFdP9C5ocOyz.5tnZM0','phpbb3','0','1','- 0- 0-','all','0','1','0','1','1','1','0','0','0','D M d, Y g:i a','1','','','0','0','0','0','0','0','0','0','1','16','0','1**Inbox$%%$2**Sent Items$%%$3**Drafts$%%$4**Trash Can','','','1','0','1','0','0','0','0','0','0','0','0','0','0','0','')
Please contact the MyBB Group for support.
The second one is because the username field is blank for some reason. What software are you importing from exactly? Dylan will likely know more no matter what though Smile
That makes sense euantor. Digging into the database tables, I keep seeing blank names...

I am importing from phpBB 3.0.8, without modifications.

With that, do you have any ideas how this can be resolved? I want to try and have my board up and set in a few days from now.
Just hang on, Dylan will be about to help you out soon.
He knows all the ins and outs of the merge system better than any of us and would be in a much better position to point you in the right direction.
(2011-05-12, 06:51 AM)- G33K - Wrote: [ -> ]Just hang on, Dylan will be about to help you out soon.
He knows all the ins and outs of the merge system better than any of us and would be in a much better position to point you in the right direction.

No problem. If all else fails, I have a backup plan in place.
Blank usernames in your phpBB3 database? Thats a new one, but may explain things a bit. Another user had this exact same SQL error issue. I believe he was also on phpBB3. Solution? Delete all the entries in the phpBB3 database that contain an empty username... OR, we can edit the SQL in the merge system:

In merge/boards/phpbb3/users.php change:
	function import()

	{

		global $import_session;

		

		// Get members

		$query = $this->old_db->simple_select("users", "*", "user_id > 0 AND username != 'Anonymous' AND group_id != 6", array('limit_start' => $this->trackers['start_users'], 'limit' => $import_session['users_per_screen']));

		while($user = $this->old_db->fetch_array($query))

		{

			$this->insert($user);

		}

	}

To:
	function import()

	{

		global $import_session;

		

		// Get members

		$query = $this->old_db->simple_select("users", "*", "user_id > 0 AND username != 'Anonymous' AND username != '' AND group_id != 6", array('limit_start' => $this->trackers['start_users'], 'limit' => $import_session['users_per_screen']));

		while($user = $this->old_db->fetch_array($query))

		{

			$this->insert($user);

		}

	}



Also in the same file change:
	function fetch_total()

	{

		global $import_session;

		

		// Get number of members

		if(!isset($import_session['total_users']))

		{

			$query = $this->old_db->simple_select("users", "COUNT(*) as count", "user_id > 0 AND username != 'Anonymous' AND group_id != 6");

			$import_session['total_users'] = $this->old_db->fetch_field($query, 'count');

			$this->old_db->free_result($query);

		}

		

		return $import_session['total_users'];

	}


To:
	function fetch_total()

	{

		global $import_session;

		

		// Get number of members

		if(!isset($import_session['total_users']))

		{

			$query = $this->old_db->simple_select("users", "COUNT(*) as count", "user_id > 0 AND username != 'Anonymous' AND username != '' AND group_id != 6");

			$import_session['total_users'] = $this->old_db->fetch_field($query, 'count');

			$this->old_db->free_result($query);

		}

		

		return $import_session['total_users'];

	}


This will prevent users w/out a username from being read by the merge system. Now if we only knew why phpBB3 didn't assign usernames for these users, we'd be in a lot better shape. :/
Okay. That actually should have been pretty fix...

Thinks...
Oh, yeah, I posted this before digging through the database yesterday.
I guess it was just the SQL that caused an emergency shutdown of my brain...


The help on these issues is greatly appreciated. Glad that there is great support behind myBB. I know it will be my software for a long time. It is most of vBulletin, but without the price.
(2011-05-12, 03:26 PM)GamerVoid Wrote: [ -> ]It is most of vBulletin, but without the price.

And basically the rest of vB functionality can be added via plugins that already exist.
Pages: 1 2 3