Check whether mysqli connection is made or not in php

PHP

This function helps to check whether connection the mysql server has been made or not.

Here is the code:

if ($mysqli->ping()) {
echo (“Our connection is ok!n”);
} else {  

    printf (“Error: %sn”$mysqli->error);
}

The $mysqli variable is a connection made via mysqli function.

Know more about mysqli ping function here.