Last active
March 6, 2016 20:05
-
-
Save ismnoiet/33bf2df5bcbefe709654 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Create a pdo instance | |
$host = 'localhost'; | |
$database_name = 'databasename'; | |
$username='username by default it is root'; | |
$password='the password associated with the current user'; | |
try{ | |
// check if there is exception | |
$pdo = new PDO("mysql:host=$host;dbname=$database_name","$username","$password"); | |
// now we've connected successfully to $database_name database | |
// and we can do whatever we want with it. | |
} | |
catch(PDOException $e){ | |
// show a message explaining what is goining wrong. | |
echo $e->getMessage(); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment