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();
?>
Keywords
Related Questions
- What are the potential reasons for not being able to select tables in phpMyAdmin when transferring a database?
- Are there any best practices for securing a website by concealing the server-side technologies being used?
- What considerations should be taken into account when designing a database schema to ensure data consistency between different tables in PHP?