Connect to MySql Database with PHP | Flutter Api Integration | Online Shop eCommerce App Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys welcome back so in the previous video uh we have basically uh understand the client server flutter and sam server architecture that is how our flutter application will communicate with the xampp server that is with our mysql database and we have created uh our api directory which is basically our api close store so now in this video what we will be doing is basically inside our directory which is api close store we are going to uh implement the connection that is we are going to establish a connection with the server uh using php back-end language so for that purpose i'm going to open up the visual studio code and now in our visual studio code first i will simply go back this one okay api close store just drag and drop this folder which is api close store in here individual studio code here okay drag and drop that here just like this so basically it will automatically uh make a reference to over this folder now what we need to do is that is inside our this folder which is api close store that is this folder okay it is now opened in our visual studio code let me just now if you hover your mouse here on this name then you will see these following icons as you can see here this icon is for creating a new file so click on this icon and let's create our first dot php file we are basically we will write a code for a connection with the mysql database or you can say with our server so let's give it name as connection dot php and press enter so our connection.php file is created after pressing enter okay this is our first dot php file now i have already told you that is this php language okay or using which we will implement our api service this php is basically a server side language or you can say a backend language so whatever file uh whatever.php files we implement inside the api cloud store that will be responsible for communicating with the xampp server that is uh with our mysql database so for writing the php code first we have to write the php starting tag and for that purpose you have to write this angle sign question mark and simply write php this is the starting take which represents that whatever now we write after this tag it will be in php language so first of all what we need to do is first we will initialize here some parameters for example the server which we will access it is the xampp server so it is using localhost we are accessing so we can say localhost okay our server is localhost local server xampp local server so let's assign this to a variable and in php language when you define or initialize a variable then before variable you have to write this dollar sign okay this dollar basically represent variable nav that is for example you first write this dollar sign and then you write here some variable name let's say a so a is now a variable to which we assign this localhost let's give this variable a proper name which is basically server so to the server host variable we assign this localhost then after it let's initialize another variable and it will be user and to use our variable we will assign the user which is basically root then password of our server or you can say our sql database so we will first initialize a variable which will be by the name password and to this password variable you will assign the password since we have no password for using the xampp server or you can say the mysql database so that's why we just give it an empty string like this then here we have to specify our database that is our database name so let's initialize a variable by the name database a base name inside this double quotes so you already know that our database name is clothes underscore app this is our database name clause underscore app so let's just write that here clothes underscore app then after it we have to uh basically you can say write a code which will basically check that is if the connection is established okay so for that purpose we write new mysqli and inside the mysqli parenthesis first we have to pass the server which is localhost so which is inside the variable server host so let's just pass the first one which is server host and then comes the user user is our root user so user comma then comes the password which is inside the password variable and then comes the database name which is inside the database variable just like this okay and let's assign the response to a variable which will be connect now so we assign this to our connect now variable and make sure to save this by simply clicking here on this save all okay file and save all so this is how we uh establish a connection with our xam server mysql or you can say with our mysql database using the localhost server which is the xampp server
Info
Channel: Muhammad Ali's Coding Cafe
Views: 16,552
Rating: undefined out of 5
Keywords: flutter php backend, flutter rest api crud, best backend for flutter, flutter api, flutter with php and mysql, flutter laravel, flutter php, flutter php api, flutter php rest api, flutter php mysql, flutter mysql chat app, flutter mysql, rest api in flutter, rest api tutorial, rest api php, third party api, third party api integration in laravel, third party api integration in php, clothes app, flutter shopping app, flutter clothing app, final year project computer science
Id: 83AM7bgT8ak
Channel Id: undefined
Length: 6min 46sec (406 seconds)
Published: Mon Sep 12 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.