SitePoint Sponsor

User Tag List

Results 1 to 14 of 14
  1. #1
    SitePoint Wizard
    Join Date
    Jul 2006
    Location
    New Zealand
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Create Database/Script/Control Panel account Creation

    I am trying to create a database/script install script

    but i want to know a couple of things

    1st is there a php function to create a cpanel account?

    and the 2nd part is creating the database username and password and databasename

    this is what i have right now

    PHP Code:
    $new_db="".randAlphaNum(5)."";

    $connection mysqli_connect("localhost""root""");
    $result =mysql_create_db($new_db,$connection);
    if(
    $result)
    {
        
    $msg "<p>Database has been created!</p>";

    It gives me this code

    Fatal error: Call to undefined function: mysql_create_db() in C:\Program Files\xampp\htdocs\installationcreation.php on line 15

    How can i fix that thats the code above.

    Is there anything i am doing wrong?

    because i am trying to create a random databasename?

    Am i going about this the right way?

  2. #2
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A lot of hosts don't allow mysql_create_db().
    You can use this class I wrote to create cPanel databases:
    www.phpclasses.org/browse/package/3534.html

  3. #3
    SitePoint Wizard
    Join Date
    Jul 2006
    Location
    New Zealand
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How do i include that class into my script its been awhile since i have worked wif classes.

  4. #4
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
    require_once('cPanel.php');
    $cPanel = new cPanel('localhost''username''password');
    $Database $cPanel->openDatabase($new_db);
    $Database->create();
    ?>

  5. #5
    SitePoint Wizard
    Join Date
    Jul 2006
    Location
    New Zealand
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks

  6. #6
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    No problem

  7. #7
    SitePoint Wizard
    Join Date
    Jul 2006
    Location
    New Zealand
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is there a whm version of class you gave me?

  8. #8
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by william232 View Post
    Is there a whm version of class you gave me?
    WHM and cPanel are one and the same...

  9. #9
    SitePoint Wizard
    Join Date
    Jul 2006
    Location
    New Zealand
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How can i tell if the database has been created or not?

  10. #10
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Connect to your MySQL server and run a SHOW DATABASES query.

  11. #11
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    $Database->create() returns true on success or false on failure.

  12. #12
    SitePoint Wizard
    Join Date
    Jul 2006
    Location
    New Zealand
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How do i know what the database name it is going to create?

  13. #13
    SitePoint Zealot
    Join Date
    Jun 2006
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It creates whatever database you tell it to. I don't really know the names of your databases.

  14. #14
    SitePoint Wizard
    Join Date
    Jul 2006
    Location
    New Zealand
    Posts
    1,300
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you have the function $new_db

    where is $new_db defined is that the name of the db or somthing?
    Code:
    <?php
    require_once('cPanel.php');
    $cPanel = new cPanel('localhost', 'username', 'password');
    $Database = $cPanel->openDatabase($new_db);
    $Database->create();
    ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •