Advertisement
Guest User

Untitled

a guest
Mar 6th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1.  
  2. // Create a pdo instance
  3. $host = 'localhost';
  4. $database_name = 'databasename';
  5. $username='username by default it is root';
  6. $password='the password associated with the current user';
  7.  
  8. try{
  9. // check if there is exception
  10. $pdo = new PDO("mysql:host=$host;dbname=$database_name","$username","$password");
  11.  
  12. // now we've connected successfully to $database_name database
  13. // and we can do whatever we want with it.
  14. }
  15. catch(PDOException $e){
  16. // show a message explaining what is goining wrong.
  17. echo $e->getMessage();
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement