PHP database connection example program
INTRODUCTION:
Connection is made using a function of php known as mysqli_connect("$dbhost","$dbuser","$dbpass","$dbname");
This function has 4 parameters
- first is your hosting name
- second is your user name on hosting
- third is password on hosting
- forth is database name
PHP CODE for PHP database connection example program
$dbhost="Localhost";
$dbuser="root";
$dbpass="";
$dbname="database";
$connect=mysqli_connect("$dbhost","$dbuser","$dbpass","$dbname");
if(!$connect)
{
echo("connection failed");
}
?>
Explanation of PHP database connection example program
hostname
It is the name of your server in this code my server is Localhost as I am coding using Xampp.
On the live server, you should have to use your server name.
User
If your username for the server in Localhost my username is root as it is default user for Xampp.
On the live server, you should have to use your username.
Pass
It is the password on the server I have no password. so it is empty.
On the live server, you should have to use your password.
On the live server, you should have to use your password.
Dpname
It is the name of your database in the server.
On the live server, you should have to use your database name.
1 Comments
Thanks A Lord For Publish In Your Blog, This Is A Great Things To Learned Many Information. Keep Posting Many Blogs Like This.
ReplyDeleteWeb portal development company in chennai, Web portal development services in chennai
Your Comment is Submitted