Home / Admin / Database connection test snippet
Duplicate Snippet

Embed Snippet on Your Site

Database connection test snippet

A snippet to test the connection to the database.

Code Preview
php
<?php
$servername = "your_server"; // change your_server with your actual database server
$username = "your_username"; // change your_username with your actual database username
$password = "your_password"; // change your_password with your actual database password
$dbname = "your_database"; // change your_database with your actual database name
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
}
echo "Success: Connected to MySQL!";

Comments

Add a Comment