How to Create Database Using PHP MySQLi
![]() |
Phpmyadmin Database Create using PHP MySQLi |
Hi In This Tutorial we will learn how to create a Database using PHP and MySQLi Commands.
You are going to create a database named "tutorial".
Create database.php file in htdocs folder and paste the below codes. and enjoy.
Codes for database.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | <?php $host = "localhost" ; //Host Name $username = "root" ; //MySQL User name(root is Default) $password = "" ; //MySQL Password(If Protected) // Creating connection with Server passing host,username and password $conn = new mysqli( $host , $username , $password ); // Checking connection if ( $conn ->connect_error) { die ( "Sorry Failed to Connect: " . $conn ->connect_error); //Displaying Error Message } // Create database $sql = "CREATE DATABASE tutorial" ; if ( $conn ->query( $sql ) === TRUE) { echo "Your Database aaa successfully created" ; } else { echo "Problems to creating database: " . $conn ->error; } $conn ->close(); ?> |
I hope you Enjoy This Article.Please Like and Share with your Friends Thank You.
Keep Visiting our Sites for More Tutorials.
No comments:
Post a Comment
Thank You for Your Comment
Note: Only a member of this blog may post a comment.