Last active
August 28, 2018 05:02
-
-
Save PunGy/d6cfe78736668c2d250bf04d8a44274b to your computer and use it in GitHub Desktop.
Connection PDO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$driver = 'mysql'; // driver | |
$host = 'localhost'; // host | |
$db_name = 'webase'; //name of databases | |
$db_user = 'user'; //name of user databases | |
$db_pass = 'pass'; // pass of user | |
$charset = 'utf8'; // charset | |
$options = [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]; | |
try{ | |
$pdo = new PDO("$driver:host=$host;dbname=$db_name;charset=$charset", | |
$db_user, $db_pass, $options); | |
}catch (PDOException $e){ | |
die("<b>Не могу подключиться к базе данных!</b><br><br><b>Ошибка:</b> $e"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment