Advertisement
Guest User

Untitled

a guest
May 8th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. <?php
  2. error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING);
  3. $username = "";
  4. $password = "";
  5. $host = "localhost";
  6. $dbname = "";
  7.  
  8. $options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');
  9.  
  10. try
  11. {
  12. $db = new PDO("mysql:host={$host};dbname={$dbname};charset=utf8", $username, $password, $options);
  13. }
  14. catch(PDOException $ex)
  15. {
  16. die("Failed to connect to the database: " . $ex->getMessage());
  17. }
  18. $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  19. $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
  20.  
  21. if(function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc())
  22. {
  23. function undo_magic_quotes_gpc(&$array)
  24. {
  25. foreach($array as &$value)
  26. {
  27. if(is_array($value))
  28. {
  29. undo_magic_quotes_gpc($value);
  30. }
  31. else
  32. {
  33. $value = stripslashes($value);
  34. }
  35. }
  36. }
  37.  
  38. undo_magic_quotes_gpc($_POST);
  39. undo_magic_quotes_gpc($_GET);
  40. undo_magic_quotes_gpc($_COOKIE);
  41. }
  42. session_start();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement