Advertisement
Guest User

Untitled

a guest
Mar 6th, 2018
769
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.39 KB | None | 0 0
  1. <?php
  2.  
  3. $hostname = 'localhost';
  4. $username = 'root';
  5. $password = '';
  6.  
  7. function testdb_connect ($hostname, $username, $password){
  8.     $dbh= new PDO("mysql:host=$hostname;dbname=users", $username, $password);
  9.     return $dbh;
  10. }
  11.  
  12. try {
  13.     $dbh = testdb_connect ($hostname, $username, $password);
  14.     echo 'Connected to database';
  15. } catch(PDOException $e) {
  16.     echo $e->getMessage();
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement