Problem creating a node with custom PHP code I wrote the following custom PHP code to create a node 

&lt;?php
define('DRUPAL_ROOT', getcwd());
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

global $user;
$title1=$node-&gt;title;
$node = new stdClass;
$node-&gt;type = 'Campaign_PlayerList';
$node-&gt;title = $title1;
$node-&gt;uid = $user-&gt;uid;
$node-&gt;language='und';
$node-&gt;field_cmp_playerid['und'][0]['value']=$user-&gt;uid;
$node-&gt;field_cmp_userscore['und'][0]['value']=1;
$node-&gt;field_cmp_usersupport['und'][0]['value']=1;
node_object_prepare($node);
node_save($node);
?&gt;


The values for field_cmp_playerid and field_cmp_attend_time are not saved.

$node-&gt;field_cmp_playerid['und'][0]['value']=$user-&gt;uid;


doesnt work and field_cmp_attend_time is the same too.

What could the problem be?

Here is a screenshot of the field management form for the Campaign Playerlist content type:
It looks from your image like field_cmp_playerid is a user reference field, which means the column name won't be value, it will be uid. Try this code:

$node-&gt;field_cmp_playerid[LANGUAGE_NONE][0]['uid'] = $user-&gt;uid;


The field_cmp_attend_time field probably isn't getting saved because it's missing from your code. It's just a date field so the column name will be value. If the date field you're using is a UNIX timestamp type, for example, the code would look like this:

$node-&gt; field_cmp_playerid[LANGUAGE_NONE][0]['value'] = REQUEST_TIME;


Just in case you want to update your field_cmp_id as well, it's a node reference so the column name becomes nid:

$node-&gt;field_cmp_id[LANGUAGE_NONE][0]['nid'] = $nid;