18 lines
529 B
PHP
18 lines
529 B
PHP
<?php
|
|
|
|
// Use environment variables for Docker deployment
|
|
$host = getenv('DB_HOST') ?: 'localhost';
|
|
$username = getenv('DB_USER') ?: 'root';
|
|
$password = getenv('DB_PASS') ?: '';
|
|
$db = getenv('DB_NAME') ?: 'custom_designs';
|
|
$port = getenv('DB_PORT') ?: '3306';
|
|
|
|
try{
|
|
// database connection
|
|
$conn = new PDO("mysql:host=$host;port=$port;dbname=$db", $username, $password);
|
|
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
}
|
|
catch(PDOException $pe)
|
|
{
|
|
die('Connection error, because: ' .$pe->getMessage());
|
|
} |