User ID problem when programmatically creating nodes
The problem is that node_submit() contains the following code.

  if (user_access('administer nodes')) {
    // Populate the "authored by" field.
    if ($account = user_load(array('name' =&gt; $node-&gt;name))) {
      $node-&gt;uid = $account-&gt;uid;
    }
    else {
      $node-&gt;uid = 0;
    }
  }


When it's not able to load the user object having $node-&gt;name as username, it sets the user ID to zero.
As you have already set the values for the node object, it is useless to pass the node to node_submit(); it would be better to just pass it to node_save().