How can one verify if PHP and MySQL are running on a website without direct access to the server?

To verify if PHP and MySQL are running on a website without direct access to the server, you can create a PHP script that connects to the MySQL database and executes a simple query. If the connection is successful and the query returns results, then both PHP and MySQL are running properly on the website.

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

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

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

echo "Connected successfully";

// Execute a simple query to verify MySQL is running
$sql = "SELECT * FROM table";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
    echo "MySQL is running";
} else {
    echo "MySQL is not running";
}

$conn->close();
?>