1) Those call will not return any useful information because they are API1 calls. API1 with return a 'status' and 'statusmgs' but they usually refer to the execution of cPanel and not the success of the functionality that you're invoking.
2) The third method should be "adduserdb" and NOT "addusertodb".
3) /usr/local/cpanel/logs/error_log should contain messages on the function errors.
4) On most cPanel systems, when you create a database or database user with API1 calls, the resulting resources are prefixed with your $cpuser name. Therefore, when you which to make the relationship, you must provide the literal names as they exist in MySQL.
$cpuser = "dave"; //my cpanel account name
$newdb = "newdatabase";
$newuser = "user";
$newpass = "password";
// create a database //
// if successful, then $cpuser with have a database 'dave_newdatabase' //
// if $cpuser_$newdb is longer that 64 characters, it will truncate //
$xmlapi->api1_query($cpuser, "Mysql", "adddb", array($newdb) );
// create a virtual database user //
// if successful, it will act just like adding a database, it
// will prefix with "$cpuser_"
// if $cpuser_$newuser is longer that 16 characters, it will truncate //
$xmlapi->api1_query($cpuser, "Mysql", "adduser",
array( $newuser, $newpass )
* At this point, the cPanel user "dave" has a database named
* "dave_newdatabase" and a virtual database user named
// create the relationship between virtual user and database //
// The "adduserdb" function should be passed the literal resource
// names, like 'dave_newdatabase' and 'dave_user'.
// On cPanel version 11.25.0 and earlier, I *think* you can get
// away with just passing variable without a prefix, however,
// in 11.25.1 (aka 11.28) and later, you are required to pass
// the literal name.
$literaldb = $cpuser . '_' . $newdb;
$literaluser = $cpuser . '_' . $newuser;
$xmlapi->api1_query($cpuser, "Mysql", "adduserdb",
array($literaldb,$literaluser,'SELECT INSERT UPDATE DELETE')
PS. you may wish to look at a blog post I made awhile back. It's concerning using the postwwwacct script to automatically generate MySQL databases and database users. I go into great length about properly making database API calls and have sample scripts using the xml-api PHP client class.