PHP MYSQLI
How to make connection MySQL database for access database.
<?php
$servername = “localhost”;
$username = “root”;
$password = “”;
$database = “databasename”;$conn = mysqli_connect($servername, $username, $password,$database);
if (!$conn) {
die(“Connection failed: ” . mysqli_connect_error());
}
echo “Connected successfully”;
?>
<?php
$servername = “localhost”;
$username = “username”;
$password = “password”;$conn = new mysqli($servername, $username, $password);
if ($conn->connect_error) {
die(“Connection failed: ” . $conn->connect_error);
}
echo “Connected successfully working”;
?>
<?php
$servername = “localhost”;
$username = “username”;
$password = “password”;
try {
$conn = new PDO(“mysql:host=$servername;dbname=myDB”, $username, $password);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
echo “Connected successfully”;
}
catch(PDOException $e)
{
echo “Connection failed: ” . $e->getMessage();
}
?>