PDO Connect - MySQL


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. $hostname = 'localhost';
  2. $username = 'username';
  3. $password = 'password';
  4.  
  5. try {
  6. $dbh = new PDO("mysql:host=$hostname;dbname=mysql", $username, $password);
  7. }
  8. catch(PDOException $e)
  9. {
  10. echo $e->getMessage();
  11. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.