xxxxxxxxxx
<?php
$host = 'localhost';
$dbname = 'your_database_name';
$username = 'root';
$password = 'password';
try {
$pdo = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
// Connection established successfully
// Perform any database operations here
} catch (PDOException $e) {
echo 'Connection failed: ' . $e->getMessage();
}
?>