Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Created by PhpStorm.
- * User: putuguna
- * Date: 2/13/2017
- * Time: 2:55 PM
- */
- class Connection{
- function getConnection(){
- $host = "localhost"; //your host
- $user = "root"; // your database username
- $password = ""; // your database password
- $dbname = "insertimage"; //your database name
- try{
- $conn = new PDO("mysql:host=$host;dbname=$dbname", $user, $password);
- $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- return $conn;
- }catch (PDOException $e){
- echo "Error while connecting database : " . $e->getMessage();
- }
- }
- }
Add Comment
Please, Sign In to add comment