PHP MySQLi Connect Examples - Web Development and Web Design Codes

Latest

Thursday, April 27, 2017

PHP MySQLi Connect Examples

How To Connect MySQLi DataBase Using PHP

PHP MySQLi Database Connect
PHP MySQLi Database Connect

Overview and Structure:


DataBase Connect is Main Factor to work with PHP MySQLi.Without DataBase Connection you Can't Access any Table In DataBase.You Can't Insert,Update,Delete,select Data and more.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
PHP MySQLi Database Connect
PHP MySQLi Database Connect

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"; //Host name
$username = "root";  //MySQL Username .'root' is default
$password = "";  //MySQL Password
$db_name="tutorial"; //Database Name

// Create connection passing host,username,password and db_name 
$conn = new mysqli($host, $username, $password,$db_name);

// Checking connection
if ($conn->connect_error) {
    die("Connection failed: " . $conn->connect_error);
} 
echo "Connected successfully"; //Successfull Message after successfully Connected
?>
 

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.