1 00:00:01,170 --> 00:00:03,810 So now what we need to do is that we need to connect to the database. 2 00:00:04,260 --> 00:00:09,090 And in order to connect to the database and we need to create a file that's going to connect us to the 3 00:00:09,090 --> 00:00:09,540 database. 4 00:00:10,080 --> 00:00:16,080 So here I'm going to get a new folder and I'm going to name it server server. 5 00:00:16,710 --> 00:00:25,680 And in this file, I'm going to add any code that has any relationship with the server, any code that 6 00:00:25,680 --> 00:00:31,200 connects to the server or gets the data from the server or data into the server is going to be here. 7 00:00:31,650 --> 00:00:35,580 So in this file I'm going to create and in this folder I'm going to create a new file called. 8 00:00:37,380 --> 00:00:40,340 Config or connection. 9 00:00:40,820 --> 00:00:42,990 It's a connection. 10 00:00:45,260 --> 00:00:46,360 Connection that beat. 11 00:00:47,450 --> 00:00:49,380 So this connection will connect to the database. 12 00:00:49,400 --> 00:00:56,150 So first I'm going to have the speech be going here and then here. 13 00:00:56,150 --> 00:00:58,740 In order to connect to the database, we need to call a function called. 14 00:00:59,430 --> 00:01:01,100 Why q i. 15 00:01:02,250 --> 00:01:03,170 Mining is key. 16 00:01:03,180 --> 00:01:09,660 Well, I underscore connect and this function takes four parameters. 17 00:01:10,020 --> 00:01:11,700 The first parameter is the host name. 18 00:01:12,450 --> 00:01:17,820 The host name is local server. 19 00:01:17,970 --> 00:01:27,330 Local localhost localhost for because I'm working I'm currently I'm currently using the local localhost. 20 00:01:28,230 --> 00:01:30,030 The second parameter is the username. 21 00:01:30,540 --> 00:01:33,900 So the username in order to get the username, you need to get to the database. 22 00:01:33,900 --> 00:01:42,330 And I have already explained this, so the username in the, in your database, if you click on user 23 00:01:42,330 --> 00:01:44,250 accounts, you should find so many accounts. 24 00:01:44,730 --> 00:01:49,680 So the account that I'm going to be using, since I'm using the localhost, I'm going to be using this 25 00:01:49,680 --> 00:01:54,210 one root localhost and the password is no, there is no password. 26 00:01:54,210 --> 00:01:57,660 Avi global privileges is all privileges. 27 00:01:57,660 --> 00:02:00,300 So again, the username is a root and the password is nothing. 28 00:02:00,960 --> 00:02:02,970 So the second parameter is the username. 29 00:02:03,480 --> 00:02:07,620 The username is root and the third parameter is the password. 30 00:02:08,310 --> 00:02:09,840 So the password is nothing. 31 00:02:09,840 --> 00:02:13,740 So we need to pass here nothing weak pass empty now quotes. 32 00:02:15,030 --> 00:02:17,280 The last parameter is the database name. 33 00:02:17,820 --> 00:02:25,890 So the database name remember the database name is BHP underscore project this database BHP underscore 34 00:02:25,890 --> 00:02:26,370 project. 35 00:02:27,000 --> 00:02:31,050 Therefore I'm going to pass here BHP Underscore Project. 36 00:02:33,660 --> 00:02:37,320 And I'm going to store this in a variable called. 37 00:02:38,580 --> 00:02:39,780 In a variable called. 38 00:02:42,270 --> 00:02:42,750 Corn. 39 00:02:43,380 --> 00:02:44,670 Corn is going to be equal to this. 40 00:02:45,150 --> 00:02:50,850 And instead of adding semicolon at the end, I'm going to say here or die. 41 00:02:51,660 --> 00:02:56,280 So what what this is going to do is that it's going to attempt to connect to the database. 42 00:02:56,640 --> 00:02:59,520 Otherwise, it's just going to kill the connection. 43 00:02:59,560 --> 00:03:01,680 If we couldn't connect for some reason. 44 00:03:01,980 --> 00:03:04,860 Any code that goes below this is never going to be executed. 45 00:03:04,860 --> 00:03:07,830 So I'm going to say here couldn't. 46 00:03:10,930 --> 00:03:11,500 Connect. 47 00:03:13,850 --> 00:03:14,710 Two database. 48 00:03:16,420 --> 00:03:17,110 Pretty simple. 49 00:03:17,410 --> 00:03:18,560 So that's it. 50 00:03:18,580 --> 00:03:22,870 In order to connect the database, we just need this line of code, and then we can use this file in 51 00:03:22,870 --> 00:03:26,050 any other file that needs connection to the database. 52 00:03:26,920 --> 00:03:30,520 Lastly, we need you to click on file and then see all.