PHP Connect To Database

<?php
$host = 'localhost';        // Database host
$db   = 'your_database';    // Database name
$user = 'your_username';    // Database username
$pass = 'your_password';    // Database password

// Create connection
$conn = mysqli_connect($host, $user, $pass, $db);

// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

echo "Connected successfully";

// Close connection when done
mysqli_close($conn);
?>

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *