Created
May 4, 2015 23:36
-
-
Save SecureCloud-biz/d41a4c44e6efcff6542a to your computer and use it in GitHub Desktop.
PDO CONNECTION
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// 웃 | |
$db_host = "127.0.0.1"; | |
$db_name = "logger"; | |
$db_user = "root"; | |
$db_pass = "root"; | |
try { | |
$db = new PDO("mysql:host=". $db_host . ";dbname=" . $db_name . ";charset=utf8;", $db_user, $db_pass, | |
array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8")); | |
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); | |
$db->setAttribute(PDO::ATTR_EMULATE_PREPARES, FALSE); | |
$db->exec("set names utf8"); | |
} catch (PDOException $e) { | |
echo "<p>Your IP has been Logged & an Email has been dispatched to an Administrator on our team. </p> | |
<p>Connection not found. : (" . | |
$e->getMessage() . ")" . | |
"</p>"; | |
die(); | |
} | |
global $db; | |
// http://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string/12118602#12118602 | |
// ALWAYS USE : setAttribute(PDO::ATTR_EMULATE_PREPARES, FALSE) | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment