Hi, I am learning php and mysqli using W3schools as my resource. I have no issues with php itself, I can retrieve data from an html form. But when I try running a mysqli select statement, I get a 404 error.
I am able to log into mysql and query the database table from my terminal. Not sure what to look for. Below is my code:
<!DOCTYPE html>
<html>
<body>
<?php
$servername = "localhost";
$username = "richie-admin";
$password = "**OMITTED**";
$dbname = "test_user";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT firstname FROM Persons";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<br> id: ". " - Name: ". $row["Firstname"]. " ". "<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>
</body>
</html>