Connecting to a MySQL database with PDO

David Carr

Tutorials PHP & MySQL

Table of Contents

<iframe frameborder="0" height="315" src="//www.youtube.com/embed/zZtfsJJqVAU" width="560"></iframe>

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

The Source Code

<?php

try {

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

 

Copyright © 2006 - 2024 DC Blog - All rights reserved.