Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.77 KB | None | 0 0
  1. In File requiring the connect:
  2.  
  3. function connect($state,$db) {
  4.     if ($state=='open') {
  5.         $_GET['db']=$db;
  6.         include('scripts/script_connect.php');
  7.     } else if ($state=='close') mysql_close();
  8. }
  9.  
  10.  
  11. In the Connect File:
  12.  
  13. if (!isset($_GET['db'])) die("I dont know which database to connect to! (db was not set as a parameter)");
  14. $database_server = "localhost";
  15. $database_user = "root";
  16. $database_password = "";
  17. $database_name = $_GET['db'];
  18.    
  19. $connection = mysql_connect($database_server, $database_user, $database_password);
  20. if (!$connection) die('Connnection could not be established due to the following error: ' . mysql_error());
  21.  
  22. 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