Skip to content

Instantly share code, notes, and snippets.

@duyet
Created April 13, 2015 04:25
Show Gist options
  • Save duyet/906eaa898574a324a23e to your computer and use it in GitHub Desktop.
Save duyet/906eaa898574a324a23e to your computer and use it in GitHub Desktop.
<?php
include('config.php');
try {
$pdo = new PDO("mysql:host=$hostname;dbname=$dbname;charset=utf8", "$username", "$pw", array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
$pdo->exec("set names utf8");
$pdo->exec("set character_set_client='utf8'");
$pdo->exec("set character_set_results='utf8'");
$pdo->exec("set character_set_connection='utf8_general_ci'");
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED);
} catch(PDOException $e) {
echo "File to get DB handle: " . $e->getMessage() . "\n";
exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment