<?php
try {

$dbh = new PDO("mysql:host=localhost;dbname=", "", "");    
foreach($dbh->query('SELECT * from contacts') as $row) {
        print_r($row);
    }
    $dbh = null;
} catch (PDOException $e) {
    print "Error!: " . $e->getMessage() . "<br/>";
    die();
}
?>