Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darsono1218/004cf7082dd6ee2ae6c0c0520fd9e5e9 to your computer and use it in GitHub Desktop.
Save darsono1218/004cf7082dd6ee2ae6c0c0520fd9e5e9 to your computer and use it in GitHub Desktop.
<?php
/**
* Created by onoPhp.blogspot.com.
*/
$host = "localhost";
$username = "root";
$password = "";
try{
$conn = new PDO("mysql:host=$host; dbname=onoPhp", $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo "berhasil terkoneksi ke database";
return $conn;
}catch (PDOException $e){
echo "ERROR : " .$e->getMessage();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment