Connect PHP to MySQL

If you want to connect PHP to MySQL, use the following code. Replace the login and connection details against those that you have received from us in your Customer Zone.

$mysql_host = "mysqlserver.loopia.se";   /* Change to correct hostname, such as mysql369.loopia.se */
$mysql_user = "your_user";
$mysql_password = "your_password";
$mysql_database = "database_name";

$mysqli = new mysqli( $mysql_host, $mysql_user, $mysql_password, $mysql_database );
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
}
Was this article helpful?

Related Articles