Please help, i cannot understand what is error

Website URL

Error Message

Fatal error: Uncaught PDOException: SQLSTATE[HY000] [2002] No such file or directory in /home/vol16_2/ Stack trace: #0 /home/vol16_2/ PDO->__construct(‘mysql:host = sq…’, ‘if0_35990726’, Object(SensitiveParameterValue)) #1 /home/vol16_2/ require(‘/home/vol16_2/i…’) #2 {main} thrown in /home/vol16_2/ on line 4

Other Information

i checked the docs and there is says not to use localhost here i selected my host still error.

Can you share your code? Be sure to block out the password


$dsn = "mysql:host =; port=3306; dbname=if0_35990726_student_data;";

$pdo = new PDO($dsn, 'if0_35990726','*********');

$query = $pdo->prepare("select * from user_data;");


$data = $query->fetchall();

$pdata = var_dump($data);

echo "<pre>{$pdata}</pre>";

done done i used mysqli and its working

A “No such file or directory” error when using MySQL always means you’re using localhost as the database hostname.

Using either MySQLi or PDO should be fine. However, please note that with a PDO connection string, you cannot add spaces to it for formatting and still expect it to work. The parameter host<space> is not the same as host, and <space> is not the same as


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.