Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Create database using php code?

Discussion in 'Database Discussion' started by Arun vm, Jul 13, 2019.

Tags:
  1. Arun vm

    Arun vm Registered

    Joined:
    Jul 13, 2019
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    kochi
    cPanel Access Level:
    Root Administrator
    I try to create Db using sql it's showing "Access Denied user"

    Here my code .
    $servername = "192.168.0.3";
    $username = "root";
    $password = "WemT3ch123$";
    // Create connection
    $conn = new mysqli($servername, $username, $password);
    // Check connection
    if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
    }


    $sql = "CREATE DATABASE myDB";
    if ($conn->query($sql) === TRUE) {
    echo "Database created successfully";
    } else {
    echo "Error creating database: " . $conn->error;
    }

    $conn->close();


    echo "string";
     
  2. keat63

    keat63 Well-Known Member

    Joined:
    Nov 20, 2014
    Messages:
    1,299
    Likes Received:
    91
    Trophy Points:
    28
    cPanel Access Level:
    Root Administrator
    I don't understand your script as I don't really know PHP.
    Did you manually create the user and password (or is that what the script does)
     
  3. cPanelLauren

    cPanelLauren Forums Analyst II Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    6,482
    Likes Received:
    508
    Trophy Points:
    263
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice