How To Practise Database Connectedness Using Php In Addition To Mysql
But earlier nosotros initiative of all at that spot are but about certainly materials required to run PHP, since nosotros are all know that PHP is a server-side scripting language. We involve a server to run PHP.In this tutorial nosotros are working offline, thence at that spot are but about basic requirements
Requirements
These are but about of the listing of required detail to follow along nosotros the tutorials, If yous create non create got whatever of the listed materials yous tin search the spider web to acquire them equally curlicue on. Here are the required items equally listed below:
- PHP Apache Server
- MySQL Server
- Code Editor eg Sublime Text,Notepad++,Brackets etc
NOTE: For the PHP Apache in addition to MySQL server yous tin download already compiled software that comprises of the 2 Server eg Xampp Server,Wampp Server etc.
STEPS
1.Install the coder that yous create got downloaded in addition to too the Server(Xampp,Wampp etc).With these installed in addition to thence yous are create to go.
2.We are going to live on using Xampp server inwards these tutorials,before yous initiative of all yous volition run Xampp server in addition to too a browser
3.After installation run the Xampp server,take glance at how it await similar spell running.
4.Open your browser in addition to type localhost/phpmyadmin to create a database.Phpmyadmin looks similar the below image.
5.Click on novel to create database.For this tutorial,we volition live on creating a database advert Basis.After clicking the novel push a page volition pop-up come inwards your database advert in addition to click Create in addition to the database volition live on created equally shown below.We involve to create tables afterward creating database but for the illustration of this tutor,we are stoping at database creation.
6.After carrying out stride v correctly,open your coder in addition to create a page db.php in addition to type the next codes equally shown below.
<?php $db['db_host'] = "localhost"; $db['db_user'] = "root"; $db['db_pass'] =""; $db['db_name'] = "basic"; foreach($db equally $key => $value){ define(strtoupper($key),$value); } $connection = mysqli_connect(DB_HOST,DB_USER,DB_PASS,DB_NAME); if($connection){ echo "We are connected"; } ?>Note:With the code typed above,you are right away connected to the Database called basic