Drupal 7: Can't Update node using php script I'm trying to update a node->body using a php script in my root directory of my Drupal 7.22 installation.I call the script through a browser (firefox) with [http://MYSITEURL/nodeupdate.php]
But somehow I don't get it to work.
Here is the code I use:

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

$nid = 9; // YES node 9 exists.
$node = node_load($nid); // where $nid is the node id

echo "$node-&gt;title &lt;br&gt;"; // Just to make sure it changes the right node and it does.

$node-&gt;body[$node-&gt;language][0]['value']   = "Test updated";

if( $node = node_submit($node)) {
    node_save($node);
    echo "Node with nid " . $node-&gt;nid . " updated!&lt;br&gt;";
}

print_r($node); // Check if we see any changes.
?&gt;


The script executes fine without any errors. Through the print_r function I can see that the "changed" field and "revision_timestamp" field are changing.
However the body doesn't change!
I have been googling and found many posts from which I gather that this is the way to do it.
What am I missing?
Make sure you're logged into the site as a user with permissions to update the specified content type, because that session will carry over to your bootstrapped script. If you're logged out, you're essentially attempting to update the node as an anonymous user in your script, and permissions will come into play.

Try adding...

global $user;
print_r($user);


...to your script and see what, if anything, that outputs.