Currently seeking new career opportunities in web development, particularly with Laravel, Hire Me

Connecting to a MySQL database with PDO

David Carr

Tutorials PHP & MySQL

Table of Contents

<iframe frameborder="0" height="315" src="//" width="560"></iframe>

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();


Laravel Modules Your Logo Your Logo Your Logo

Become a sponsor

Help support the blog so that I can continue creating new content!


My Latest Book

Modular Laravel Book - Laravel: The Modular way

Learn how to build modular applications with Laravel Find out more

Subscribe to my newsletter

Subscribe and get my books and product announcements.

Learn Laravel with Laracasts

Faster Laravel Hosting

© 2006 - 2024 DC Blog. All code MIT license. All rights reserved.