How to connect to database using PHP and MySQL
<?php
$dbname="your db name";
$server="your server name e.g. localhost";
$username="your username e.g. root";
$password=" your password";
$connect = mysqli_connect($dbname,$server,$username,$password) or die(mysqli_error());
if($connect)
{
echo "Database connection successfully..";
}else
{
echo "error while connecting to the database";
}
?>
$dbname="your db name";
$server="your server name e.g. localhost";
$username="your username e.g. root";
$password=" your password";
$connect = mysqli_connect($dbname,$server,$username,$password) or die(mysqli_error());
if($connect)
{
echo "Database connection successfully..";
}else
{
echo "error while connecting to the database";
}
?>
Comments
Post a Comment