Alternative to drupal_goto
Perhaps something like this:

function mymodule_page_callback($parent_nid){

  global $user;
  try{
    // Create new node, assumes default LANGUAGE_NONE
    $node = new stdClass();
    $node-&gt;title = 'Title';
    $node-&gt;type = 'my_type';
    $node-&gt;language = LANGUAGE_NONE;
    $node-&gt;uid = $user-&gt;uid; 
    $node-&gt;status = 1; 
    node_object_prepare($node); // Sets some defaults.
    $node = node_submit($node); // Prepare node for saving
    node_save($node); // Returns $node by reference with nid

    // Set entity reference on parent node
    $parent = node_load($parent_nid);
    $parent-&gt;field_entity_reference[LANGUAGE_NONE][] = array(
      'target_id' =&gt; $node-&gt;nid
    );
    // Save parent
    node_save($parent);
    // Go to edit form for new child node
    drupal_set_message("Node created");
    drupal_goto('node/'.$node-&gt;nid.'/edit');
  }catch(Exception $e){
    watchdog_exception('my_module', $e);
    drupal_set_message("A problem occured creating the node", 'error');
    drupal_goto(); // front page
  }

}