mysqli_connect
This code is setting up a connection to the MySQL database. If there is an error connecting to the database, an error message will be displayed and the program will exit.
Shortcut: mysqli_connect
<?php
// MySQli connection
$mysqli = new mysqli("localhost","user","password","db");
// Check connection
if ($mysqli -> connect_errno) {
echo "Failed to connect to MySQL: " . $mysqli -> connect_error;
exit();
}
?>