Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if (!$config){
- $error = 'No config! Please, specify config before using `db.inc.php`';
- include $_SERVER['DOCUMENT_ROOT'] . '/error.html.php';
- exit();
- }
- $mysqli = new mysqli('localhost', $config['username'], $config['password']);
- if ($mysqli->connect_errno) {
- echo "Failed to connect to MySQL: " . $mysqli->connect_error;
- exit();
- }
- if (!$mysqli->set_charset('utf8'))
- {
- $output = 'Unable to set Database connection encoding';
- include $_SERVER['DOCUMENT_ROOT'] .'/output.html.php';
- exit();
- }
- if (!$mysqli->select_db($config['dbname']))
- {
- $error = 'Unable to locate database.';
- include $_SERVER['DOCUMENT_ROOT'] . '/error.html.php';
- exit();
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment