Connection with MySql database : mysqli_connect()

MYSQLI mysqli_connect()

MySqli is database driver for connection with MySQL database.

Connect MySQL database using PHP script  




Here mysqli_connect is inbuild function of php for connection with MySql database.

In this function, you required four parameters as shown in above script.

  • hostname: your database hosting name if in your computer then write localhost for local database use else writes database provider name.
  • username: your database username. if in the local server then write root.
  • password: Your database password. if in the local server then leave is blank. As shown in blow script
  • database_name: name of your database.


// Local connection script


if(mysqli_connect_errno()){    //

echo “Error : Database could not connect : “. mysqli_connect_error(); // if databse not connected then show error



Next Create Database