Hello! Im new to drupal so i have not yet much experience but i'm trying to setup a website to gain experience.

I created a node type called lending which should hold the value of titel, user, date and extra information. There are 1500 values which i needed to add to the node type but who is going to do that manually? so i made a script which inserts them into the database. Now if i want to add new content to that node it returnes the following error:

DOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '25' for key 'vid': UPDATE {node} SET vid=:db_update_placeholder_0 WHERE (nid = :db_condition_placeholder_0) ; Array ( [:db_update_placeholder_0] => 25 [:db_condition_placeholder_0] => 1329 ) in node_save() (line 1121 of /home/sites/evilpeople.cats/public_html/olc/modules/node/node.module).

This started occuring after i added the values to the database, any idea on how to fix this?

Comments

mikelmao’s picture

Also, everytime i try to submit a new node it will increase the duplication value by 1 so i would have to do it 1500 times before reaching the end of that error.. The value must be somewhere i can change, any ideas?

ludo1960’s picture

posting your code might give someone a fighting chance of helping you!

mikelmao’s picture

There's no code, iv worked through the interface. If it's the script i wrote to input the values into the DB its the following:

  $sql = new mysqli('localhost', '*******', '**********', '*******');
  $test = array();
  $file = fopen("namen.txt", "r");
  while(!feof($file))
    {
    $test[]= explode(" ", fgets($file));    
    
    }             
  fclose($file);
      
  $i = 3; // to match vid with nid
  foreach($test AS $namen) {
   $i++;
    if(!$sql->query('INSERT INTO `node` (`vid`, `type`, `language`, `title`, `uid`, `status`, `created`, `changed`, `comment`, `promote`, `sticky`, `tnid`, `translate`) VALUES ('. $i .', "docent", "und", "'. $namen[0] .'", 1, 1, 1352123057,  1352123057, 1, 1, 0, 0, 0)')) {
      echo 'Error: '. $sql->error .'<br />';
    } else {
      
     echo 'The following node has been created: '. $namen[0] .'<br />';
    }
  }
      
ludo1960’s picture

Sorry, but I have no idea what you are trying to achieve, if you want to import nodes just use the node import module. You need to add a bit a of clarity of what you are trying to do here. There are plenty of good folks round here that will be happy to lend a hand!