PHP MySQL Connect - Web Development and Web Design Codes

Latest

Monday, April 17, 2017

PHP MySQL Connect

How To Connect MySQL DataBase Using PHP

PHP MySQL Connect to Database
PHP MySQL Connect

Overview and Structure:


DataBase Connection is Main Factor to work with PHP MySQL.Without DataBase Connection you Can't Access any Table In DataBase.You Can't Insert,Update,Delete,select DataB.DataBase Connection is First Step to Learn PHP MySQL
What You Will Need:
Go To XAMPP=>htdocs=>create a new file connect.php
Now copy and Paste The Below Codes and paste it connect.php file

DataBase Structure and Overview:

Open any Web Browser and Type :http://localhost/phpmyadmin in your Browser address Bar then Hit Enter.
Create a New DataBase "Tutorial"
DataBase Name: Tutorial.

Code For Connect.php for Connecting DataBase and Selecting DataBase:

<?php
$host="localhost";//Name of Your Host
$username="root"; //MySQL user If Password Protected Else Type "root" by Defaults.
$password=""; //MySQL Password if Protected else Leave it Blank
$db_name="tutorial"; //Your DataBase Name

//Connecting To MySQL Server by Passing Host,Username and Password name
mysql_connect("$host","$username","$password")or die("Sorry Failed To Connect MySQL Server");

//Selecting MySQL Database Selection
mysql_select_db("$db_name")or die("Sorry Failed To Select Database");
echo "Successfully Connected to DataBase";
?>
 

If You Like This Article Please Like and Share with Your Friends.
Don't Forget to Ask comments.Thank You.

No comments:

Post a Comment

Thank You for Your Comment

Note: Only a member of this blog may post a comment.