Advertisement
Guest User

Untitled

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