As you know, mySQL extension is deprecated in PHP 5.5, and will be removed in future. MySQLi is improved PHP extension of MySQL which is introduced in PHP 5. We have millions of applications using PHP MySQL and needs to be updated on MySQLi or PDO (PHP Data Objects).

Here is a very simple integration guide of MySQLi how to connect to a database, how to  run a query and insert records etc..

mySQLi connection with the object method:

<?php
  $sql = new mysqli('localhost','root','password','dbname');
?>

 

mySQLi connection with the procedural method:

<?php
  $con = mysqli_connect('localhost','root','password','dbname');
?>

 

Simple procedure with complete code with procedural method:

<?php  
//Create the connection  

  $con = mysqli_connect("HostName","UserName","password","DBName") or die("Some error occurred during connection " . mysqli_error($con));  

// Write query

  $strSQL = "SELECT username FROM MyTable";

// Execute the query.

  $query = mysqli_query($con, $strSQL);
  while($result = mysqli_fetch_array($query))
  {
    echo $result["username"]." ";
  }

// Close the connection
  mysqli_close($con);

?>