I've just installed xampp and I'm running a MySQL db locally on phpMyAdmin. I'm trying to output the contents of a database via a .php doc, but I'm getting two warnings when trying to do so:
Warning: mysqli::__construct(): The server requested authentication method unknown to the client [caching_sha2_password] in C:\xampp\htdocs\footfallTracker\test.php on line 20
Warning: mysqli::__construct(): (HY000/2054): The server requested authentication method unknown to the client in C:\xampp\htdocs\footfallTracker\test.php on line 20 Connection failed: The server requested authentication method unknown to the client
Here's the code I'm using:
<?php
$servername = "localhost";
$username = "root";
$password = "*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19";
$dbname = "footfall_tracking";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT ID, Location, Date FROM footstep_count";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "ID: " . $row["ID"]. " - Location: " . $row["Location"]. " - Date: " . $row["Date"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>