Guest User

Untitled

a guest
Feb 3rd, 2017
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. <?php
  2. # Version: v2.11, Version Date: June 2016, Author: Silvio Mc Gurk (smcgurk@stmartins.edu)
  3. class dbConn {
  4. public function connect() {
  5.  
  6. # Database Name and Host
  7. $hostname = "localhost";
  8. $database = "formdatabase";
  9. $username = "root";
  10. $password = "root123";
  11. $dsn = "mysql:dbname=$database;host=$hostname";
  12.  
  13. # Attempting connection with selected database
  14. $connect = new mysqli($hostname, $username, $password, $database);
  15.  
  16. # Check status of connection fail on error
  17. if ($connect->connect_error) {
  18. echo “Error connecting to database”;
  19. }
  20.  
  21. # Return the mysqli connection
  22. return $connect;
  23. }
  24. }
  25. ?>
Add Comment
Please, Sign In to add comment