Answer the question
In order to leave comments, you need to log in
(PDO) Error connecting to MySQL?
The code itself
<?php
$host = "vh44.timeweb.ru"; (локалхост пробовал)
$db = "users";
$user = "cv41923_fartu";
$pass = "mypassword";
$charset = "utf8";
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
$opt = array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC
);
$pdo = new PDO($dsn, $user, $pass, $opt);
Answer the question
In order to leave comments, you need to log in
1) Look at the logs, everything that happens on the servers of hosters is usually accompanied by a bunch of logs, in this case, PHP logs should help.
2) In the hosting panel, in the database settings, data for the connection is usually indicated, perhaps you have a non-standard connection port or some other tricks from the hoster. See the settings in the panel.
3) If the hosting allows - turn on the output of errors and warnings, this will greatly simplify the installation and configuration work.
PS: as a completely crazy option - pdo is not included in the list of php extensions for this hosting, if there are php settings there - check, but this should be visible from the logs.
and if you specify the full path to the host?
i.e. from http://
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question