Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Not a member yet? Click here to register.
Forgot Password?

PRoblem: New user gets userid=16777215

Asked Modified Viewed 7,932 times
Z
Zidane55
Z
  • Member, joined since
  • Contributed 90 posts on the community forums.
  • Started 26 threads in the forums
  • Started this discussions
asked
Member

Hello. When a new user registres on my site, he becomes the userid = 16777215 every time.

Does anyone know why this happens?

When a new user activates his account he get this message "your account is activated ... Duplicate entry '16777215' for key 'PRIMARY'

Can anyone help?
0 replies

24 posts

M
mawe4585
M
  • Member, joined since
  • Contributed 84 posts on the community forums.
  • Started 34 threads in the forums
answered
Member

maybe a defect of the mysql table so that the auto-inc counter is corrupt?
0 replies
S
smokeman
S
  • Veteran Member, joined since
  • Contributed 920 posts on the community forums.
  • Started 79 threads in the forums
answered
Veteran Member

I told him to repair the table too - that did not fix it.
0 replies
M
Moregelen
M
Oooooh.. is that what Deep Corruption does? Ooopsie...
.. so, how do I heal without Holy Radiance spam anyway? I forgot...
  • Junior Member, joined since
  • Contributed 37 posts on the community forums.
  • Started 3 threads in the forums
answered
Junior Member

Has he tried clearing the table completely? So that it is completely remade?

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]dbquery('TRUNCATE TABLE ' . DB_USERS);[/syntaxhighlighter]

(truncate drops the table and then remakes it)

Then you can register a new account and manually set it as the super admin. Hopefully that will reset whatever happened to your increment key.
0 replies
Z
Zidane55
Z
  • Member, joined since
  • Contributed 90 posts on the community forums.
  • Started 26 threads in the forums
  • Started this discussions
answered
Member

I tried doing what he told me in post number 2. But now the userid changes to 16777216 and when I make a new user 16777217 and a new 16777218..

hmm
0 replies
K
Korcsii
K
Former Senior Developer (v7.02) and Hungarian Translator
  • Member, joined since
  • Contributed 132 posts on the community forums.
  • Started 8 threads in the forums
answered
Member

If you have only 15 users... set all user_id to 1,2,3...15, and then try to repair the table.
0 replies
P
PolarFox
P
  • Veteran Member, joined since
  • Contributed 1,633 posts on the community forums.
  • Started 29 threads in the forums
answered
Veteran Member

Quote

maybe a defect of the mysql table so that the auto-inc counter is corrupt?

agreed, you must fix counter, something like this

just an example, not for real use:

Quote

ALTER TABLE fusion_users AUTO_INCREMENT = _YOUR_MAXIMUM_USER_ID_

_YOUR_MAXIMUM_USER_ID_ - YOUR MAXIMUM real USER ID.
0 replies
Z
Zidane55
Z
  • Member, joined since
  • Contributed 90 posts on the community forums.
  • Started 26 threads in the forums
  • Started this discussions
answered
Member

Polarfox. How should I do this exactly?
0 replies
P
PolarFox
P
  • Veteran Member, joined since
  • Contributed 1,633 posts on the community forums.
  • Started 29 threads in the forums
answered
Veteran Member

Try to use (make some backup first)

replace 100 to your max user ID

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]
<?php
dbquery("ALTER TABLE ".DB_USERS." AUTO_INCREMENT = 100"wink;
?>[/syntaxhighlighter]
0 replies
M
Moregelen
M
Oooooh.. is that what Deep Corruption does? Ooopsie...
.. so, how do I heal without Holy Radiance spam anyway? I forgot...
  • Junior Member, joined since
  • Contributed 37 posts on the community forums.
  • Started 3 threads in the forums
answered
Junior Member

Your webhost most likely has phpMyAdmin installed; you might want to just go in there and alter the structure of the table rather than running code. That way you have an interface to verify it worked as well. Just go to the OPERATIONS tab for the table and set the auto_increment field to the number of rows you have +1
0 replies
P
PolarFox
P
  • Veteran Member, joined since
  • Contributed 1,633 posts on the community forums.
  • Started 29 threads in the forums
answered
Veteran Member

Right.
0 replies
Z
Zidane55
Z
  • Member, joined since
  • Contributed 90 posts on the community forums.
  • Started 26 threads in the forums
  • Started this discussions
answered
Member

Okay. I have 15 user now. So I change the auto_increment field to 16 ?
0 replies
M
mawe4585
M
  • Member, joined since
  • Contributed 84 posts on the community forums.
  • Started 34 threads in the forums
answered
Member

change it to the MAX_CURRENT_USER_ID + 1
could be there was a user more who was deleted, so look for the user_id field.
0 replies
Z
Zidane55
Z
  • Member, joined since
  • Contributed 90 posts on the community forums.
  • Started 26 threads in the forums
  • Started this discussions
answered
Member

hm, how do I do that?

I went to operation inside the user_table and changed the auto_increment to 16. But how do I change it to MAX_CURRENT_USER_ID + 1 ?

Sorry, but I am a bit new in php and database :(
0 replies
J
JoiNNN
J
JoiNNN 10
  • Veteran Member, joined since
  • Contributed 850 posts on the community forums.
  • Started 100 threads in the forums
answered
Veteran Member

LOL.
MAX_CURRENT_USER_ID is the user_id with the highest value, in your case might be 15, highest user_id is not equal to the number of your registered users if you deleted a user for example.

img594.imageshack.us/img594/8195/84176221.png
img560.imageshack.us/img560/3669/65589553.png

If you done it already there's not need to change anything else. Do the new registered users have proper IDs?

Here is a complete script that will change the AUTO_INCREMENT based on user_id with the highest value, paste it in a custom page and preview it then delete it, don't save the page.
<?php
$result = dbquery("SELECT MAX(user_id) FROM ".DB_USERS);
$id = dbarray($result);
$maxid = $id['MAX(user_id)'] + 1;

$result = dbquery("ALTER TABLE ".DB_USERS." AUTO_INCREMENT = ".$maxid);
if ($result) {
echo "Success :)<br />New AUTO_INCREMENT = ".$maxid;
} else {
echo "Something went wrong :(<br />Please try again";
}
?
Edited by JoiNNN on 10-03-2012 22:50,
0 replies
K
Korcsii
K
Former Senior Developer (v7.02) and Hungarian Translator
  • Member, joined since
  • Contributed 132 posts on the community forums.
  • Started 8 threads in the forums
answered
Member

But the problem is that, his highest user id is about 16777215.

He have to delete all users with high user_id, or change the id to lower.
0 replies
M
Moregelen
M
Oooooh.. is that what Deep Corruption does? Ooopsie...
.. so, how do I heal without Holy Radiance spam anyway? I forgot...
  • Junior Member, joined since
  • Contributed 37 posts on the community forums.
  • Started 3 threads in the forums
answered
Junior Member

just stick this in a custom page

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]<?php
$users = dbquery("SELECT user_name FROM " . DB_USERS . " ORDER BY user_id"wink;
$count = 1;
while ($user = dbarray($users)) {
dbquery("UPDATE " . DB_USERS . " SET user_id = " . $count . " WHERE user_name = '" . $user['user_name'] . "'"wink;
$count++;
}

dbquery("ALTER TABLE " . DB_USERS . " AUTO_INCREMENT = " . $count);

$users = dbquery('SELECT user_id,user_name FROM ' . DB_USERS . ' ORDER BY user_id'wink;
print "<table>";
while ($user = dbarray($users)) {
print "<tr><td>" . $user['user_name'] . "</td><td>" . $user['user_id'] . "</td></tr>";
}
print "</table>";
?>[/syntaxhighlighter]

and then preview the page. Should list all the user names and their new ids.
Edited by Moregelen on 11-03-2012 01:54,
0 replies
J
JoiNNN
J
JoiNNN 10
  • Veteran Member, joined since
  • Contributed 850 posts on the community forums.
  • Started 100 threads in the forums
answered
Veteran Member

Quote

Moregelen wrote:

Lol.. that is exactly what the code I posted does =D At least I know you agree with me?


Oh LOL :D, I started writing the code got a little busy and when i came back didn't checked for new posts.
Well, deleted mine yours looks cleaner :).
0 replies
M
Moregelen
M
Oooooh.. is that what Deep Corruption does? Ooopsie...
.. so, how do I heal without Holy Radiance spam anyway? I forgot...
  • Junior Member, joined since
  • Contributed 37 posts on the community forums.
  • Started 3 threads in the forums
answered
Junior Member

To be honest, he should have a bit more to the code to make sure that he isn't trying to double insert the primary key... buuut there shouldn't be a problem since it should be sorting by user_id, ascending by default, so there shouldn't be any overlap. But making assumptions and all that isn't really a good idea when coding, I've learned =D

In fact, added the order by clause which should take care of that =D
0 replies
M
mawe4585
M
  • Member, joined since
  • Contributed 84 posts on the community forums.
  • Started 34 threads in the forums
answered
Member

problem would be if these users posted threads etc, with this mod the connection between user and thread is gone
0 replies
M
Moregelen
M
Oooooh.. is that what Deep Corruption does? Ooopsie...
.. so, how do I heal without Holy Radiance spam anyway? I forgot...
  • Junior Member, joined since
  • Contributed 37 posts on the community forums.
  • Started 3 threads in the forums
answered
Junior Member

You're right, I didn't even think of that.

This should help with cleaning up the orphans, but I don't know if I missed any tables. But at least you can see how to easily add a table and column that needs to be updated. This is assuming of course he hadn't gotten around to running the code yet, 'cause if he did the links are well and truly gone and he will have to do it manually =(

[syntaxhighlighter brush=php,first-line=1,highlight=0,collapse=false,html-script=false]<?php
$users = dbquery("SELECT user_name,user_id FROM " . DB_USERS . " ORDER BY user_id"wink;
$count = 1;
$tables = array(
array("table" => DB_DOWNLOADS, "column" => "download_user"wink,
array("table" => DB_FORUM_POLL_VOTERS, "column" => "forum_vote_user_id"wink,
array("table" => DB_MESSAGES, "column" => "message_to"wink,
array("table" => DB_MESSAGES, "column" => "message_from"wink,
array("table" => DB_PHOTOS, "column" => "photo_user"wink,
array("table" => DB_PHOTO_ALBUMS, "column" => "album_user"wink,
array("table" => DB_POLL_VOTES, "column" => "vote_user"wink,
array("table" => DB_POSTS, "column" => "post_author"wink,
array("table" => DB_RATINGS, "column" => "rating_user"wink,
array("table" => DB_SUBMISSIONS, "column" => "submit_user"wink,
array("table" => DB_SUSPENDS, "column" => "suspended_user"wink,
array("table" => DB_THREADS, "column" => "thread_author"wink,
array("table" => DB_THREAD_NOTIFY, "column" => "notify_user"wink
);
while ($user = dbarray($users)) {
dbquery("UPDATE " . DB_USERS . " SET user_id = " . $count . " WHERE user_name = '" . $user['user_name'] . "'"wink;
foreach ($tables as $table) {
dbquery("UPDATE " . $table['table'] . " SET " . $table['column'] . " = " . $count . " WHERE " . $table['column'] . " = " . $user['user_id']);
}
$count++;
}

dbquery("ALTER TABLE " . DB_USERS . " AUTO_INCREMENT = " . $count);

$users = dbquery('SELECT user_id,user_name FROM ' . DB_USERS . ' ORDER BY user_id'wink;
print "<table>";
while ($user = dbarray($users)) {
print "<tr><td>" . $user['user_name'] . "</td><td>" . $user['user_id'] . "</td></tr>";
}
print "</table>";
?>[/syntaxhighlighter]
0 replies

Labels

None yet

Statistics

  • Views 0 views
  • Posts 24 posts
  • Votes 0 votes
  • Topic users 7 members

7 participants

K
K
Former Senior Developer (v7.02) and Hungarian Translator
  • Member, joined since
  • Contributed 132 posts on the community forums.
  • Started 8 threads in the forums
S
S
  • Veteran Member, joined since
  • Contributed 920 posts on the community forums.
  • Started 79 threads in the forums
M
M
Oooooh.. is that what Deep Corruption does? Ooopsie...
.. so, how do I heal without Holy Radiance spam anyway? I forgot...
  • Junior Member, joined since
  • Contributed 37 posts on the community forums.
  • Started 3 threads in the forums
M
M
  • Member, joined since
  • Contributed 84 posts on the community forums.
  • Started 34 threads in the forums
P
P
  • Veteran Member, joined since
  • Contributed 1,633 posts on the community forums.
  • Started 29 threads in the forums
J
J
JoiNNN 10
  • Veteran Member, joined since
  • Contributed 850 posts on the community forums.
  • Started 100 threads in the forums
Z
Z
  • Member, joined since
  • Contributed 90 posts on the community forums.
  • Started 26 threads in the forums
  • Started this discussions

Notifications

Track thread

You are not receiving notifications from this thread.

Related Questions

Not yet