This script assigns variables to access your database. You will need to insert this script on each page where you plan to access data from your database.
Ensure your server name, username and password are correct
<?php
$servername = "localhost";
$username = "username";
$password = "password";
$db = "db_name";
// Create connection
$conn = mysqli_connect($servername, $username, $password,$db);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
echo "Connected successfully"; // this is only for testing purposes and can be removed
?>
At the start of every new PHP file in your project that requires connection to the SQL database include this line of code at the top of your code.
<?php
include('connect.php');
?>