How can a PHP project access a MySQL database without a traditional server setup?

To access a MySQL database without a traditional server setup, you can use a local development environment like XAMPP or WAMP that includes Apache, MySQL, and PHP. This allows you to run a server on your local machine and interact with the MySQL database without needing a separate server setup.

<?php
$servername = "localhost";
$username = "root";
$password = "";
$database = "your_database_name";

// Create connection
$conn = new mysqli($servername, $username, $password, $database);

// Check connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>