Skip to content

Instantly share code, notes, and snippets.

@ahanafi
Last active October 5, 2020 01:52
Show Gist options
  • Save ahanafi/87483bde8ffc4385629a224bf28ce005 to your computer and use it in GitHub Desktop.
Save ahanafi/87483bde8ffc4385629a224bf28ce005 to your computer and use it in GitHub Desktop.
Koneksi PHP dan MySQL dengan PDO
<?php
$hostname = "localhost";
$username = "root";
$password = "secret-password";
$dbname = "my_database";
try {
$connect = new PDO("mysql:dbname=$dbname;host=$hostname", $username, $password);
} 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