Connect to Database via PHP on a Managed Server

Please Note:

The text on this page was translated by translation software. A revised version from our editors will be available soon.

For Managed Dedicated Servers

These sample scripts show you how to connect to the MySQL database in PHP.

MySQL 5.1

<?php

$hostname="localhost:/tmp/mysql5.sock";
$database="db123456789";
$benutzername="dbo123456789";
$passwort="********";

$link = mysql_connect("$hostname", "$benutzername", "$passwort", "$database");
if (!$link) {
die('keine Verbindung möglich: ' . mysql_error());
}
echo 'Verbindung erfolgreich';
mysql_close($link);

?>

Replace the example $database, $username and $password with the credentials of your database. leave $hostname at 'localhost:/tmp/mysql5.sock'.

MySQL 5.5

<?php

$hostname="localhost";
$database="db123456789";
$benutzername="dbo123456789";
$passwort="********";

$link = mysql_connect("$hostname", "$benutzername", "$passwort", "$database");
if (!$link) {
die('keine Verbindung möglich: ' . mysql_error());
}
echo 'Verbindung erfolgreich';
mysql_close($link);

?>

Replace the example $database, $username and $password with the credentials of your database. The $hostname should be 'localhost'.