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!

Access MySQL via PHP script on another server?

Discussion in 'Database Discussion' started by anta40, Jan 20, 2018.

  1. anta40

    anta40 Registered

    Joined:
    Jan 19, 2018
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    Jakarta, Indonesia
    cPanel Access Level:
    Website Owner
    Let's say I have a VPS with a public IP 123.123.100.101
    I put a PHP script in there which is going to read a table from my blog database (say
    the database name is h123084_wp702)

    So, first I have to grant remote access, right?


    Then the issue is to update my connection code. I have this:
    PHP:
    <?php

    $host 
    ="";
    $user ="";
    $pass ="";
    $db    ="h123084_wp702";
    $con mysqli_connect($host$user$pass$db) or die("Cannot connect to database...");

    ?>
    What are the correct values of $host, $user, and $pass?

    I cannot update my original post with attachments, because it was detected as spam :(
    So here are the pictures, anyway.
    cp1.jpg
    cp2.jpg
     
    #1 anta40, Jan 20, 2018
    Last edited by a moderator: Jan 20, 2018
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    45,532
    Likes Received:
    1,966
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    Hello,

    The host is the domain name or IP address of the remote server that hosts the MySQL database, and the username/password fields are for the database username and the password for that database username.

    Thank you.
     
    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