Skip to content

Instantly share code, notes, and snippets.

/database.php Secret

Created December 28, 2017 19:22
Show Gist options
  • Save anonymous/4031bbc7ce368d02df999a4faca4a293 to your computer and use it in GitHub Desktop.
Save anonymous/4031bbc7ce368d02df999a4faca4a293 to your computer and use it in GitHub Desktop.
<?php
class Database
{
// specify your own database credentials
private $host = "localhost";
private $db_name = "obiezaca_db";
private $username = "root";
private $password = "";
public $conn;
// get the database connection
public function getConnection()
{
$this->conn = null;
try
{
$this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password);
$this->conn->exec("set names utf8");
}
catch(PDOException $exception)
{
echo "Connection error: " . $exception->getMessage();
}
return $this->conn;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment