The mysqli_connect() function in PHP is used to connect you to the database. In the previous version of the connection mysql_connect() was used for connection and then there comes mysqli_connect() where i means improved version of connection and is more secure than mysql_connect().
mysqli_connect ( "host", "username", "password", "database_name" )
- host: It is optional and it specify the host name or IP address. In case of local server localhost is used as a genral keyword to connect local server and run the program.
- username: It is optional and it specify mysql username. In local server username is root.
- Password: It is optional and it specify mysql password.
- database_name: It is database name where operation perform on data. It also optional.
- It returns an object which represent MySql connection. If connection failed then it return FALSE.
Program: Below is the implementation of mysqli_connect() function.
Database Connection Successfully.
- PHP | pi( ) Function
- PHP | Ds\Map map() Function
- PHP | Ds\Map last() Function
- PHP | pow( ) Function
- PHP | Ds\Set last() Function
- PHP | Ds\Set first() Function
- PHP | Ds\Set add() Function
- PHP | Ds\Map first() Function
- PHP Ds\Map sum() Function
- PHP | max( ) Function
- PHP | Ds\Set contains() Function
- PHP | min( ) Function
- PHP | Ds\Map get() Function
- PHP | exp() Function
- PHP | Ds\Set xor() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.