Connecting to the database with PHP

There are many ways to connect to a database with PHP. im going to show you a very simple one. Im going to be connecting to the my SQL database. My SQL is an open-source relational database.

I have a database called CMS in PHP myadmin.

And I have a table called categories.

First I create a file called db.php and add the mysqli_connect() which open a new connection to mysql server.

I then pass it some parameters localhost, username, empty string and save it in a variable called $connection.

I then check the $connection and if the connection is true I well display

I write about web development!