Saving additional node fields programmatically I have the following content type called stars with the following fields:

Title
Body
Distance (this is an added text field)


Here's what I have to save the node, but how do I add the distance field?

$node = new stdClass();
$node-&gt;type = "stars";
$node-&gt;status = 0;
$node-&gt;uid = $user-&gt;uid;
$node-&gt;title = 'This is the title';
$node-&gt;sticky = 0;
$node-&gt;language = 'en';

// Let's add standard body field
$node-&gt;body['und'][0]['format'] = 'filtered_html';
$node-&gt;body['und'][0]['value'] = 'Body info';

$node-&gt;revision = 0;

node_save($node);
You'd need to set the value for the Distance field just like you have already for the Body field. Lets assume that the name of your Distance field is field_star_distance. (To find the name of your field, check if you have the Field UI module enabled and head over to the Manage fields page for your content type)

// Your code
$node-&gt;{'field_star_distance'}[LANGUAGE_NONE][0]['value'] = 100;
// Your code


The general skeleton for setting the value for a field of an entity is:

$entity-&gt;{$field_name}[$language][$delta][$field_property] = $value


To understand the different field properties for a given field (like value in our example here), you need to look up its schema (see hook_field_schema() and see text_field_schema())

To see if $delta can be  &gt; 1, you need to check the cardinality of the field instance.