Answers for "php mysqli connection check"

PHP
0

php mysqli connection check

/* Procedural style */
<?php
 
$conn = mysqli_connect("localhost", "user", "password", "database");

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

/* check if server is alive */
if (mysqli_ping($conn)) {
    printf ("Our connection is ok!\n");
} else {
    printf ("Error: %s\n", mysqli_error($conn));
}

/* close connection */
mysqli_close($conn);
?>
Posted by: Guest on August-04-2021

Code answers related to "php mysqli connection check"

Browse Popular Code Answers by Language