<?php
/* create a connection object which is not connected */
$link = mysqli_init();
/* set connection options */
mysqli_options($link, MYSQLI_INIT_COMMAND, "SET AUTOCOMMIT=0");
mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 5);
/* connect to server */
mysqli_real_connect($link, 'localhost', 'my_user', 'my_password', 'world');
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
printf ("Connection: %s\n.", mysqli_get_host_info($link));
mysqli_close($link);
?>