I need to create a NEW MySQL database, NEW Table, and add users using php script.
I am using Go Daddy Shared Hosting with cPanel Deluxe..
I read that I will need to use UAPI, or XML API or something like that..
I have xmlapi.php in the same directory as my test php file.
I also read that Go Daddy Shared hosting does not allow this to work?
Can anyone help ?
<?php
include("xmlapi.php");
$db_host = 'website.com';
$cpaneluser = 'cpanelusername';
$cpanelpass = 'cpaneluserpassword';
$databasename = 'testdb';
$databaseuser = 'newdbuser'; // Warning: in most of cases this can't be longer than 8 characters
$databasepass = 'password'; // Warning: be sure the password is strong enough, else the CPanel will reject it
$xmlapi = new xmlapi($db_host);
$xmlapi->password_auth("".$cpaneluser."","".$cpanelpass."");
$xmlapi->set_port(2082);
$xmlapi->set_debug(1);//output actions in the error log 1 for true and 0 false
$xmlapi->set_output('array');//set this for browser output
//create database
$createdb = $xmlapi->api1_query($cpaneluser, "Mysql", "adddb", array($databasename));
//create user
$usr = $xmlapi->api1_query($cpaneluser, "Mysql", "adduser", array($databaseuser, $databasepass));
//add user
$addusr = $xmlapi->api1_query($cpaneluser, "Mysql", "adduserdb", array("".$cpaneluser."_".$databasename."", "".$cpaneluser."_".$databaseuser."", 'all'));
?>
I am using Go Daddy Shared Hosting with cPanel Deluxe..
I read that I will need to use UAPI, or XML API or something like that..
I have xmlapi.php in the same directory as my test php file.
I also read that Go Daddy Shared hosting does not allow this to work?
Can anyone help ?
<?php
include("xmlapi.php");
$db_host = 'website.com';
$cpaneluser = 'cpanelusername';
$cpanelpass = 'cpaneluserpassword';
$databasename = 'testdb';
$databaseuser = 'newdbuser'; // Warning: in most of cases this can't be longer than 8 characters
$databasepass = 'password'; // Warning: be sure the password is strong enough, else the CPanel will reject it
$xmlapi = new xmlapi($db_host);
$xmlapi->password_auth("".$cpaneluser."","".$cpanelpass."");
$xmlapi->set_port(2082);
$xmlapi->set_debug(1);//output actions in the error log 1 for true and 0 false
$xmlapi->set_output('array');//set this for browser output
//create database
$createdb = $xmlapi->api1_query($cpaneluser, "Mysql", "adddb", array($databasename));
//create user
$usr = $xmlapi->api1_query($cpaneluser, "Mysql", "adduser", array($databaseuser, $databasepass));
//add user
$addusr = $xmlapi->api1_query($cpaneluser, "Mysql", "adduserdb", array("".$cpaneluser."_".$databasename."", "".$cpaneluser."_".$databaseuser."", 'all'));
?>
Last edited by a moderator: