Using Drupal 5.1, and when adding term to vocabulary (category) I receive the error:
"user warning: Duplicate entry '104' for key 1 query: INSERT INTO term_data (tid, name, description, vid, weight) VALUES (104, 'event', '', 9, 0) in /hsphere/local/home/getsited/alternativehealth.getsited.co.nz/includes/database.mysql.inc on line 172."
Problem:
Due to bug in taxonomy.module not getting the correct value out for the next available key.
Fix:
On line 480 of modules/taxonomy.module change this
$form_values['tid'] = db_next_id('{term_data}_tid');
to
$form_values['tid'] = db_next_id('{term_data}.tid');
Quite similar problem to http://drupal.org/node/121399 although it uses a different fix, hence a new post - hope this is ok.
Hope this helps someone!
Comments
Comment #1
getsited commentedSorry after looking further into this is seems to be have been a problem with the sequences table, NOT THE CODE. Please disregard the post above.
Comment #2
joeking1 commentedi had the same problem:
user warning: Duplicate entry '127' for key 1 query: INSERT INTO term_data (tid, name, description, vid, weight) VALUES (201, 'test', '', 7, 0)
i did the change on the taxonomy.module and then it worked fine...i wonder what makes you say its not the solution....
Comment #3
getsited commentedOk. First things first, if you changed anything in the taxonomy.module file, change it back!
EG. If you had changed line 480 of modules/taxonomy.module to this
$form_values['tid'] = db_next_id('{term_data}.tid');
you need to change it back to this
$form_values['tid'] = db_next_id('{term_data}_tid');
then have a look at your sequences table. this is a table that keeps track of the IDs used in other tables. So where it has the value
{term_data}_tid or similar, make sure the next key it is going to assign is something like 200 or something - just to get it out of trying to assign low numbers.
hope this makes sense. let me know how you get on.