PHP Classes

File: db.php

Recommend this page to a friend!
  Packages of Channaveer Hakari   PHP Dependent Drop Down Tutorial   db.php   Download  
File: db.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Dependent Drop Down Tutorial
Create dependent dropdowns using jQuery AJAX
Author: By
Last change:
Date: 5 years ago
Size: 704 bytes
 

 

Contents

Class file image Download
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL | E_STRICT);
require_once 'config.php';
$host           = $config['database']['host'];
$db_name        = $config['database']['db_name'];
$db_username    = $config['database']['db_username'];
$db_password    = $config['database']['db_password'];
$dsn            = 'mysql:host=' . $host . ';dbname=' . $db_name;
$options        = [
    PDO::ATTR_ERRMODE            => PDO::ERRMODE_EXCEPTION,
    PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
    PDO::ATTR_EMULATE_PREPARES   => false,
];
try {
    $pdo = new PDO($dsn, $db_username, $db_password);
} catch (PDOException $e) {
    exit($e->getMessage());
}