Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement