PHP – Connect to database

Connect to database

$host_name = “dbhost.com”;
$database = “dbname”;
$user_name = “dbusername”;
$password = “dbpassword”;

$connect = mysqli_connect($host_name, $user_name, $password, $database);
if (mysqli_connect_errno())
{
echo “Failed to connect to MySQL: ” . mysqli_connect_error();
}
else echo ‘You are connected to the <strong> ‘.$database.'</strong> database<br /><br />’

It's only fair to share...Tweet about this on TwitterShare on FacebookEmail this to someoneShare on Google+
This entry was posted in PHP/MySQL. Bookmark the permalink.