I have a MySQLi connection object to connect to mysql as this :
require_once('config.php');
//new mysqli object
$mysqli = new mysqli(MYSQL_HOSTNAME, MYSQL_USERNAME, MYSQL_PASSWORD, MYSQL_DATABASE);
/* check connection */
if ($mysqli->connect_errno) {
printf("Connect failed: %s
", $mysqli->connect_error);
exit();
}
and I've included this file into any files to have connection
Is it right way? I think in my every files , I will have new connection to MySQL.