I have a problem, when I want to connect my PHP code to my database, This error shows me in the picture But when I connect my database via the terminal this is working
https://i.stack.imgur.com/PoIW7.png
<?php
$host='localhost';
$db='canda';
$user='root';
$pass='123456789';
try{
new PDO("mysql:host=".$host
."; dbname=".$db,
$user, $pass);
}catch (PDOException $e) {
echo $e;
}
PDOException: SQLSTATE[HY000] [2002] No such file or directory in /Users/mac/Desktop/test.php:11 Stack trace: #0 /Users/mac/Desktop/test.php(11): PDO->__construct('mysql:host=loca...', 'root', 'password') #1 {main}