Skip to content

Instantly share code, notes, and snippets.

@EZFRICA
Last active January 15, 2020 23:48
Show Gist options
  • Save EZFRICA/f6bb2b8ea8892edbf8fa6c5d4a9eb9dd to your computer and use it in GitHub Desktop.
Save EZFRICA/f6bb2b8ea8892edbf8fa6c5d4a9eb9dd to your computer and use it in GitHub Desktop.
PHP MySQL
<?php
$servername = "localhost";
$username = "root";
$password = "Admin password";
try {
$conn = new PDO("mysql:host=$servername;dbname=essai", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "Connected successfully";
}
catch(PDOException $e)
{
echo "Connection failed: " . $e->getMessage();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment