Click here to Skip to main content
15,877,967 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "course_enrolment";
 $conn = mysqli_connect($servername, $username, $password, $dbname);
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
<!DOCTYPE html>
<title>Minerva Timetable</title>
<h1>The Minerva bus company Timetable</h1>

What I have tried:

I've tried to google help which suggests I have a semi colon missing but it's not, any help greatly received. 1st year college student. I'm using Notepad++ and xampp
Updated 19-Jul-22 23:26pm
SeeSharp2 24-Jun-21 16:38pm    
Maybe the space before $conn? I don't do php but your code looks good, according to w3schools,

1 solution

Have you tried using mysqli_connect_errno() to check if connection failed. Something like
if (mysqli_connect_errno() <> 0) {
    die("Connection failed: " . mysqli_connect_error());
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900