Advertisement
Guest User

Untitled

a guest
Mar 5th, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. <?php
  2. if (!isset($_GET['page'])) {
  3. header('Location: /main');
  4. exit();
  5. }
  6.  
  7. ini_set('display_errors','Off');
  8. try {
  9. $database_host = "localhost";
  10. $database_name = "NAME";
  11. $database_user = "USER"; //name for phpMyAdmin in bplaced
  12. $database_pass = "*******"; //password in phpMyAdmin in bplaced
  13. global $db;
  14. $db = mysqli_connect($database_host, $database_user, $database_pass, $database_name) or
  15. die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
  16. mysqli_set_charset($db, "utf8");
  17. }
  18.  
  19. if (isset($_COOKIE['hash'])) {
  20. $sql = $db->query("SELECT * FROM `users` WHERE `hash` = " . $db->quote($_COOKIE['hash']));
  21. if ($sql->rowCount() != 0) {
  22. $row = $sql->fetch();
  23. $user = $row;
  24. }
  25. }
  26.  
  27. try
  28. {
  29. //Do something here which might cause an exception
  30. }
  31. catch(Exception $e)
  32. {
  33. //You are here means that the exception occurred now do something else here.
  34. }
  35.  
  36. try
  37. {
  38. print "this is our try blockn";
  39. throw new Exception();
  40. }
  41. catch (Exception $e)
  42. {
  43. print "something went wrongn";
  44. }
  45. finally
  46. {
  47. print "This part is always executedn";
  48. }
  49.  
  50. <?php
  51. if (!isset($_GET['page'])) {
  52. header('Location: /main');
  53. exit();
  54. }
  55.  
  56. ini_set('display_errors', 'Off');
  57. try {
  58. $database_host = "localhost";
  59. $database_name = "NAME";
  60. $database_user = "USER"; //name for phpMyAdmin in bplaced
  61. $database_pass = "*******"; //password in phpMyAdmin in bplaced
  62. global $db;
  63. $db = mysqli_connect($database_host, $database_user, $database_pass, $database_name) or die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
  64. mysqli_set_charset($db, "utf8");
  65. }
  66. catch (Exception $e) {
  67. // do something
  68. }
  69.  
  70. if (isset($_COOKIE['hash'])) {
  71. $sql = $db->query("SELECT * FROM `users` WHERE `hash` = " . $db->quote($_COOKIE['hash']));
  72. if ($sql->rowCount() != 0) {
  73. $row = $sql->fetch();
  74. $user = $row;
  75. }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement