Advertisement
Guest User

asfsdfasdf

a guest
Apr 7th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. <?php
  2.  
  3. //This script creates a connection to a database at $connection.
  4. //Should be included when querying to database.
  5.  
  6. $server = "mysql.nith.no";
  7. $port = "3306";
  8. $username = "nguhuo15";
  9. $password = "nguhuo15";
  10. $db = "nguhuo15";
  11.  
  12. // Create connection
  13. $connection = mysqli_connect($server, $username, $password, $db, $port);
  14.  
  15. // Check connection
  16. if ($connection->connect_error) {
  17. die("Connection failed: " . $connection->connect_error);
  18. }
  19.  
  20. // Close connection
  21. // Call when db connection is no longer needed
  22. // Takes in 1 connection, including connection created on include.
  23. function closeConnection($connection){
  24. mysqli_close($connection);
  25. }
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement