PHP & MySQL | Tutorials

David Carr

Connecting to a MySQL database with PDO

This video covers connection to a database using PDO in a try catch block with Exceptions.

The Source Code


try {

    $db = new PDO('mysql:host=localhost;dbname=temp','root','root');
} catch (Exception $e) {
    echo $e->getMessage();


Domains are often purchased from multiple providers, keeping track of where a domain is and its DNS settings can be tricky. Domain Mapper solves this by listing all your domains in one place. View your DNS settings and receive reminders to renew your domains. Try it today.

Support my work by donating with PayPal.

Subscribe to my newsletter

Subscribe and get my books and product announcements.

© 2009 - 2021 DC Blog. All code MIT license. All rights reserved.