mysqli -> connect code example
Example 1: mysqli connect
<?php
$mysqli = new mysqli("localhost","my_user","my_password","my_db");
// Check connection
if ($mysqli -> connect_errno) {
echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
exit();
}
?>
Example 2: mysqli connect
mysqli_connect(host, username, password, dbname, port, socket)
Example 3: mysqli connect
$mysqli = new mysqli(host, username, password, dbname, port, socket)