Create a user Programmatically in Drupal 6.22 i was trying to create a new user Programmatically in drupal 6.22 but i can't seem to get it working.
I need to make a web service that can do a few things, one being create a new user.
This webservice is going to be consumed by a mobile device.
I was just trying to test the user_save from outside drupal in just a simple php file and it doesn't seem to work. I just need to know what i'm doing wrong.

Here is my code

&lt;?php
    require_once(includes/bootstrap.inc);
    drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
    // Get an array of roles
    $roles = user_roles();
//Basic account information
$user = array(
    'name' =&gt; 'username',
    'pass' =&gt; 'Password',
    'mail' =&gt; 'email',
    'status' =&gt; 1,
   'init' =&gt; 'email',
    'roles' =&gt; array(array_search('authenticated user', $roles) =&gt; 1),
);
// See if the user exists by calling Drupal's user_load()
$existing_user = user_load(array('name' =&gt; $user['name']));
    if (!$existing_user-&gt;uid) {
    // Save the user
    $user = user_save(NULL, $user);
    } 
?&gt;


EDIT: Added the drupal_bootstrap, still not working for me.
Looks like you've included the bootstrap.inc but you haven't actually bootstrapped drupal.

Example:

require_once(includes/bootstrap.inc);
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);