I am trying to display a simple table of one of the tables in my mySQL database, but am getting the below message when I load the page.
connection failed:Connection refused
Username Password PhysicianID
I have tested the credentials I use in my code over and over and am 100% sure that they are correct. I am unsure as to what could be causing this issue. Below is my php code:
<!DOCTYPE html>
<head>
<TITLE>Table That will NOT load</TITLE>
</head>
<body>
<table>
<tr>
<th>Username</th>
<th>Password</th>
<th>PhysicianId</th>
</tr>
<?php
$conn = mysqli_connect('host', 'root', 'password', 'MySQLDatabase');
if(!$conn) {
die("connection failed:" . mysqli_connect_error());
}
$sql = "Select * from Users";
$result = $conn-> query($sql);
if($result -> num_rows > 0) {
while ($row = $result-> fetch_assoc()) {
echo "<td><td>". $row["username"] ."</td><td>". $row["username"] ."</td><td>". $row[
"password"] ."</td><tr>";
}
echo "</table>";
}
else {
echo "0 result";
}
$conn-> close();
?>
</table>
</body>
</html>