Guest User

Untitled

a guest
Nov 9th, 2017
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Created by PhpStorm.
  5. * User: putuguna
  6. * Date: 2/13/2017
  7. * Time: 2:55 PM
  8. */
  9. class Connection{
  10. function getConnection(){
  11. $host = "localhost"; //your host
  12. $user = "root"; // your database username
  13. $password = ""; // your database password
  14. $dbname = "insertimage"; //your database name
  15.  
  16. try{
  17. $conn = new PDO("mysql:host=$host;dbname=$dbname", $user, $password);
  18. $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  19. return $conn;
  20. }catch (PDOException $e){
  21. echo "Error while connecting database : " . $e->getMessage();
  22. }
  23. }
  24. }
Add Comment
Please, Sign In to add comment