connect to database

Before you can access data in a database, you must create a connection to the database.

define('DB_HOST', '127.0.0.1');
define('DB_USER', 'root');
define('DB_PASS', 'mypass');
define('DB_NAME', 'snippet_lib');

$con = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);

* check connection *
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}