I'm trying to connect to a database using PDO but I'm getting this error message:
Connection failed: SQLSTATE[HY000] [2002] No such file or directory
I'm using mamp
and thanks for the help
Php code:
<?php
$dsn ="mysql: host=local host:8888; dbname=fruit";
$username="root";
$password="my password";
Try{
$conn= new PDO($dsn,$username,$password);
$conn->setAttribute(PDO:ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch(PDOException $e)
{
echo "Connection failed: ".$e->getMessage();
}
?>