Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- In File requiring the connect:
- function connect($state,$db) {
- if ($state=='open') {
- $_GET['db']=$db;
- include('scripts/script_connect.php');
- } else if ($state=='close') mysql_close();
- }
- In the Connect File:
- if (!isset($_GET['db'])) die("I dont know which database to connect to! (db was not set as a parameter)");
- $database_server = "localhost";
- $database_user = "root";
- $database_password = "";
- $database_name = $_GET['db'];
- $connection = mysql_connect($database_server, $database_user, $database_password);
- if (!$connection) die('Connnection could not be established due to the following error: ' . mysql_error());
- mysql_select_db($database_name, $connection) or die('The database could not be selected due to the following error:' . mysql_error());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement