Create Connection with SQL Database in PHP
How to create connection with mysql database using PHP ?
So for this first create a database in myPhpAdmin and then use that name in mysqli default constructor by default the password was null and user name is root. If you are using XAMP then the servername is localhost.
<?php
$servername = "localhost";
$username = "root";
$password = Null;
$dbname = "paging";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
} else{
echo "Connection Sucssful";
}
?>
copy paste above code save in conn.php file and run on localhost like localhost/conn.php
So for this first create a database in myPhpAdmin and then use that name in mysqli default constructor by default the password was null and user name is root. If you are using XAMP then the servername is localhost.
<?php
$servername = "localhost";
$username = "root";
$password = Null;
$dbname = "paging";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
} else{
echo "Connection Sucssful";
}
?>
copy paste above code save in conn.php file and run on localhost like localhost/conn.php
Post a Comment