diff options
author | Chaoyi Zha <summermontreal@gmail.com> | 2014-11-21 00:47:06 +0300 |
---|---|---|
committer | Chaoyi Zha <summermontreal@gmail.com> | 2014-11-21 00:47:06 +0300 |
commit | 5e48ba468b62619b35c7273aa91d638340574146 (patch) | |
tree | 03763628bd425fa553e726b61da33290aeb675bb | |
parent | 0dbf6d5a05d8d33390f62f3b3d2336e6a5fa0d10 (diff) |
better connection error structure in general
-rw-r--r-- | admin/error.php | 3 | ||||
-rw-r--r-- | error.php | 24 | ||||
-rw-r--r-- | req.php | 8 |
3 files changed, 5 insertions, 30 deletions
diff --git a/admin/error.php b/admin/error.php deleted file mode 100644 index 3e2b549..0000000 --- a/admin/error.php +++ /dev/null @@ -1,3 +0,0 @@ -<?php -header('Location:../error.php'); -// Redirect to correct error file diff --git a/error.php b/error.php deleted file mode 100644 index 1e62b83..0000000 --- a/error.php +++ /dev/null @@ -1,24 +0,0 @@ -<?php -$req_noredirect = true; -require_once('req.php'); -require_once('header.php'); - -echo "<h2>Error:</h2><br />"; -echo "<ul>"; -$err = 0; -if (!$mysqli) { - $err++; - echo "<li>Could not connect to database. Please contact the administrator."; -} -if ($insecure == TRUE && $_SESSION['role'] == 'adm') { - $err++; - echo "<li>You are seeing the following message because you are an administrator. Your MySQL database is potentially unsafe. P - lease make sure Polr's database receives an UTF8 encoding. </li>"; -} -if ($err<1) { - echo "<li>No errors to report.</li>"; -} - -echo "</ul>"; - -require_once('footer.php'); @@ -5,9 +5,11 @@ $debug = 0; // Set to 1 in order to enable debug mode (shows sensitive database $footer = "© Copyright 2014 $wsn. Powered by <a href='http://github.com/cydrobolt/polr'>Polr</a> ver $version build $reldate"; $hidefooter = true; // Let's hide this for now //connect to mysql with $mysqli variable -$mysqli = new mysqli($host, $user, $passwd, $db) or $wp = 1; //If cannot connect, then set var $wp to 1 -if (!$mysqli && $req_noredirect = true) { - header('Location:error.php'); +$mysqli = new mysqli($host, $user, $passwd, $db) ; +if ($mysqli->connect_errno) { + echo "Database error. If you are a member of the general public, contact an administrator to solve this issue. + If you are the administrator of this website, please make sure your database is turned on and that credentials are correct."; + die(); } // Attempt to set Charset as UTF8 to avoid real_escape_string vulnerabilities if (!$mysqli->set_charset("utf8")) { |