Connecting to the Mysql Database
Before we can do anything in the database, we must connect to it. This is achieved by creating a connection file that we will call mysqli_connect.php.
The code for the connection file is as follows:
<?php // Defineing the constants: DEFINE ('DB_USER', 'sriram'); DEFINE ('DB_PASSWORD', 'code@vector'); DEFINE ('DB_HOST', 'localhost'); DEFINE ('DB_NAME', 'myTestDb'); // Next we assign the database connection to a variable that we will call $dbcon: $dbcon = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error () ); // Finally, we set the language encoding.as utf-8 mysqli_set_charset($dbcon, 'utf8'); ?>