Created
February 26, 2021 23:36
-
-
Save gent-fella-health/78b44870665d8d5982ab3aa114596415 to your computer and use it in GitHub Desktop.
PHP MySQL Connect to database.
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 | |
$dbHost = '127.0.0.1'; | |
$dbPort = '3308'; | |
$dbName = 'name'; | |
$dbUser = 'user'; | |
$dbPassword = 'password'; | |
try { | |
new pdo( | |
"mysql:host=$dbHost:$dbPort;dbname=$dbName", | |
$dbUser, | |
$dbPassword, | |
array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION) | |
); | |
die('Cool!'); | |
} catch (PDOException $e) { | |
die(json_encode(array('title' => 'Unable to connect.', 'message' => $e->getMessage()))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment