View difference between Paste ID: 7ZQ6FHd6 and 9tcYehLH
SHOW: | | - or go back to the newest paste.
1
<?php
2
error_reporting(E_ALL); 
3
ini_set("display_errors", 1); 
4
5
try {
6
7
    $dsn = "mysql:dbname=bacula;host=localhost;charset=utf8;";
8
    $dbuser = "root";
9
    $dbpass = "";
10
11
    $options = array (
12
        PDO::ATTR_CASE => PDO::CASE_LOWER,
13
        PDO::ATTR_ERRMODE    => PDO::ERRMODE_EXCEPTION,
14
        PDO::ATTR_PERSISTENT => true
15
    );
16
17
    $pdo = new PDO($dsn, $dbuser, $dbpass, $options);
18
19
    $stmt = $pdo->query("select * from client");
20
    $stmt->execute();
21
    
22
    while($row = $stmt->fetch(PDO::FETCH_BOTH)){
23
      echo $row->name . "\n";
24
    }
25
    
26
} catch (PDOException $e){
27
    echo "(". $e->getCode() . ") " .$e->getMessage() . " at line: " . $e->getLine();
28
}