Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!isset($_GET['page'])) {
- header('Location: /main');
- exit();
- }
- ini_set('display_errors','Off');
- try {
- $database_host = "localhost";
- $database_name = "NAME";
- $database_user = "USER"; //name for phpMyAdmin in bplaced
- $database_pass = "*******"; //password in phpMyAdmin in bplaced
- global $db;
- $db = mysqli_connect($database_host, $database_user, $database_pass, $database_name) or
- die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
- mysqli_set_charset($db, "utf8");
- }
- if (isset($_COOKIE['hash'])) {
- $sql = $db->query("SELECT * FROM `users` WHERE `hash` = " . $db->quote($_COOKIE['hash']));
- if ($sql->rowCount() != 0) {
- $row = $sql->fetch();
- $user = $row;
- }
- }
- try
- {
- //Do something here which might cause an exception
- }
- catch(Exception $e)
- {
- //You are here means that the exception occurred now do something else here.
- }
- try
- {
- print "this is our try blockn";
- throw new Exception();
- }
- catch (Exception $e)
- {
- print "something went wrongn";
- }
- finally
- {
- print "This part is always executedn";
- }
- <?php
- if (!isset($_GET['page'])) {
- header('Location: /main');
- exit();
- }
- ini_set('display_errors', 'Off');
- try {
- $database_host = "localhost";
- $database_name = "NAME";
- $database_user = "USER"; //name for phpMyAdmin in bplaced
- $database_pass = "*******"; //password in phpMyAdmin in bplaced
- global $db;
- $db = mysqli_connect($database_host, $database_user, $database_pass, $database_name) or die('Connect Error (' . mysqli_connect_errno() . ') ' . mysqli_connect_error());
- mysqli_set_charset($db, "utf8");
- }
- catch (Exception $e) {
- // do something
- }
- if (isset($_COOKIE['hash'])) {
- $sql = $db->query("SELECT * FROM `users` WHERE `hash` = " . $db->quote($_COOKIE['hash']));
- if ($sql->rowCount() != 0) {
- $row = $sql->fetch();
- $user = $row;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement