Click here to Skip to main content
15,441,434 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<?php
$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>
<html>
<head>
<title>Minerva Timetable</title>
</head>
<body>
<h1>The Minerva bus company Timetable</h1>
<?php


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
Posted
Updated 19-Jul-22 23:26pm
Comments
SeeSharp2 24-Jun-21 16:38pm    
Maybe the space before $conn? I don't do php but your code looks good, according to w3schools, https://www.w3schools.com/php/func_mysqli_connect.asp

1 solution

Have you tried using mysqli_connect_errno() to check if connection failed. Something like
PHP
...
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