Problem by creating nodes in loop i am new to drupal and trying to migrate same pages to drupal. I am able to create one node via druapals API, but when trying to create more nodes in a loop it doesn't work...

This is the working code:

    define('DRUPAL_ROOT','/var/www');
    require '/var/www/includes/bootstrap.inc';
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);        


    #construct the new node object
    $node = new stdClass();

    #specify node properties
    $node-&gt;uid = 1;
    $node-&gt;title = "new node";
    $node-&gt;log ="";
    $node-&gt;status = 1;
    $node-&gt;comment = 1;
    $node-&gt;promote = 0;
    $node-&gt;sticky = 0;
    $node-&gt;type = 'veranstaltung';
    $node-&gt;language = 'und';
    $node-&gt;created = time();
    $node-&gt;changed = $node-&gt;created;
    $node-&gt;tnid=0;
    $node-&gt;translate=0;
    $node-&gt;body['und'][0]['value']="&lt;h1&gt;content&lt;/h1&gt;";
    $node-&gt;body['und'][0]['format']="filtered_html";
    $node-&gt;body['und'][0]['safe_value']="&lt;h1&gt;content&lt;/h1&gt;";

    #save node
    node_save($node)    


If i put this in a for-loop and change the body and title each iteration it doesn't work.. The code is inside an external php script. Even copy the code and paste behind it again with other body and title does not work.

Thanks a lot
Objects are passed by reference in PHP; therefore $node-&gt;nid is being set after your first go around the for loop. If $node-&gt;nid is set, no new node is created, so, I'd unset($node-&gt;nid) after each node_save() and give it another try.