<?php
$servername = "server_ip";
$database = "databasename";
$username = "username";
$password = "password";
try
{
$conn = new PDO("mysql:host=$servername:3306;dbname=$database", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
?>
try this and then google the error :)