For Managed Servers

These sample scripts will 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 access data of your database. $hostname should be left as '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 entries for $database, $username and $password with the access data of your database. $hostname should be left as 'localhost'.

 

You can find the access data  under the item MySQL.