Gossamer Forum
Home : Products : Links 2.0 : Discussions :

duplicate key error

Quote Reply
duplicate key error
I get this error when processing the form for add.cgi
What does this error exacly mean? I've located the code that returns this message:

# We keep checking for the next available key, or until we've tried 50 times
# after which we give up.
while ($status eq "duplicate key error" and $db_key_track) {
return "duplicate key error" if ($counter++ > 50);
$status = &validate_record (%in);
What is the keys? What is wrong you think?

Quote Reply
Re: duplicate key error In reply to
I found the error my self.
If you add a new record to the database and set the record ID to a lower number than the last added records ID number, the script will update your linksid.txt with the new lower id number.

Then when the script tries to validate a new record it'll take the ID number in linksdb.txt, increase it 1 step, and then check that no other record got that ID number. In my case it found one with that ID, which it'll do in most cases, and returned this error...

Maybe this is a bug, or maybe the Links programmer thought noone would be that stupid to add a new record with a lower ID number than the last one? :D

(To fix this it's kind of easy, just check if the new ID number that should be written to the linksdb.txt is lower than the existing, then don't update the file.)