> ## Knowledge Base Index
> Fetch the complete knowledge base index at: https://krystal-dev.crisp.help/sitemap.xml
> Use this file to discover available pages before exploring further.
> Pure-Markdown content can be obtained by appending a '.md' suffix to the content URLs listed in the sitemap (without the trailing slash).

# How to connect to a MySQL database using PHP

The hostname to use when connecting to one of your cPanel MySQL databases from a web script running within the same cPanel account is `localhost`.

As a quick guide, you can use the following PHP code to make a connection.

``` $hostname = "localhost"; // mysql hostname - always use localhost$database = "databasename"; // substitute your mysql database name$username = "username"; // substitute your mysql user name$password = "somethinghardtoguess"; // your mysql users's password$con = mysqli_connect($hostname, $username, $password, $database) or die(mysql_error()); // make connection to mysql```

* * *

* * *