Database Connection In Php With Mysqli Example

Open a Connection to MySQL

Before we can access data in the MySQL database, we need to be able to connect to the server:

Connection error checking with object method:

Simple procedure with complete code with procedural method:

Close the Connection

The connection will be closed automatically when the script ends. To close the connection before, use the following:

Thanks for reading my article about “ Database Connection In Php With Mysqli Example”. If you like this article do me favor by sharing it with your friends.

Digital Technology Hub