There are different programming languages currently in use, of which some are open source while others are proprietary. Open source basically refers to a program in which the source code is available to the public, free of cost, for use or for modification from its original design.
Here we will create database for which we will use programmatic method with the help of PHP and MYSQL .
Write a program to create a Database with the help of PHP and MySQL ?
Syntax of PHP
<?php
//Content goes here
?>
NOTE - // double forward slash is the comment in PHP.
<?php $host = 'localhost'; $user = 'root'; $pwd = ''; $conn = mysqli_connect($host, $user, $pwd); if(!$conn ) { die("Connection failed : " . mysqli_connect_error()); } $sql = "CREATE DATABASE loginpanel"; if(mysqli_query($conn, $sql)) { echo "Database created successfully"; } else { echo "Error Creating Database : " . mysqli_errno($conn); } mysqli_close($conn); ?>
Explaination
=> $host = 'localhost'; $host is a variable which is used to
store a value like localhost and localhost
is our server.
=> $user = 'root'; $user as it same just like above the sentence but
here is one difference and the difference is that its a user like root
user of our xampp machine localhost.
=> $pwd = '';
In this variable
here is empty value of $pwd variable because we dont want any type of problem
means no need of authentication.
Now you must be thinking what is
this authentication!! dont worry click here for more information.
=> $conn is our new variable.
=> mysqli_connect() - The mysqli_connect() function attempts to open a
connection to the MySQL Server running on host which can be either a host name
or an IP address.
Passing the NULL value or the
string "localhost" or variable name to this parameter.
Now we
will check the connection whether the connection is working successfully or
not!! Actually here we will "if and else" condition.
=> die() - The die() function prints a message and exits the
current script.
=> mysqli_connect_error() - PHP
mysqli_connect_error() function returns an string value representing the
description of
the error from the last connection call, incase of a
failure. If the connection was successful
this function returns Null.
=> mysqli_error() - The mysqli_error() function
is used to return the error in the most recent MySQL function call that
failed.
=> mysqli_query()- mysqli_query()
what it returns. The return value could be a boolean(true/false)
=> mysqli_close()
- The close() / mysqli_close() function closes a previously opened database
connection.
Simply run in your favourite browser by xampp server
Disclaimer
All tutorials are for informational and educational purposes only and have been made using our own routers, servers, websites and other vulnerable free resources. we do not contain any illegal activity. We believe that ethical hacking, information security and cyber security should be familiar subjects to anyone using digital information and computers. Hacking Truth is against misuse of the information and we strongly suggest against it. Please regard the word hacking as ethical hacking or penetration testing every time this word is used. We do not promote, encourage, support or excite any illegal activity or hacking.
0 comments:
Post a Comment
For Any Tech Updates, Hacking News, Internet, Computer, Technology and related to IT Field Articles Follow Our Blog.