I am trying to use a PHP connection to connect MySQL Database which is on phpmyadmin. I have uploaded all the files in infinityfree for web hosting. I am using Xampp and the connection I am trying to use is this:
$host="localhost:3306";
$username="root";
$password="";
$dbname="moviedb";
try {
$conn = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo "Connection failed: " . $e->getMessage();
}
The website appeared but I can't log in or register and there was a message that kept staying in the top left corner of the screen saying:
Connection failed: SQLSTATE[HY000] [2002] No such file or directory
Any help regarding this issue would be really appreciated.