So now what we need to do is that we need to connect to the database.
And in order to connect to the database and we need to create a file that's going to connect us to the
database.
So here I'm going to get a new folder and I'm going to name it server server.
And in this file, I'm going to add any code that has any relationship with the server, any code that
connects to the server or gets the data from the server or data into the server is going to be here.
So in this file I'm going to create and in this folder I'm going to create a new file called.
Config or connection.
It's a connection.
Connection that beat.
So this connection will connect to the database.
So first I'm going to have the speech be going here and then here.
In order to connect to the database, we need to call a function called.
Why q i.
Mining is key.
Well, I underscore connect and this function takes four parameters.
The first parameter is the host name.
The host name is local server.
Local localhost localhost for because I'm working I'm currently I'm currently using the local localhost.
The second parameter is the username.
So the username in order to get the username, you need to get to the database.
And I have already explained this, so the username in the, in your database, if you click on user
accounts, you should find so many accounts.
So the account that I'm going to be using, since I'm using the localhost, I'm going to be using this
one root localhost and the password is no, there is no password.
Avi global privileges is all privileges.
So again, the username is a root and the password is nothing.
So the second parameter is the username.
The username is root and the third parameter is the password.
So the password is nothing.
So we need to pass here nothing weak pass empty now quotes.
The last parameter is the database name.
So the database name remember the database name is BHP underscore project this database BHP underscore
project.
Therefore I'm going to pass here BHP Underscore Project.
And I'm going to store this in a variable called.
In a variable called.
Corn.
Corn is going to be equal to this.
And instead of adding semicolon at the end, I'm going to say here or die.
So what what this is going to do is that it's going to attempt to connect to the database.
Otherwise, it's just going to kill the connection.
If we couldn't connect for some reason.
Any code that goes below this is never going to be executed.
So I'm going to say here couldn't.
Connect.
Two database.
Pretty simple.
So that's it.
In order to connect the database, we just need this line of code, and then we can use this file in
any other file that needs connection to the database.
Lastly, we need you to click on file and then see all.