I have a database that contains the pathway to audio files. This data is stored in a column called Language1. The actual audio file is stored in a folder called Language1.
I want to check that the pathways in the database match the filename that is in the directory.
The first 10 files are in the folder, but the code is not recognising that. I want the code to read through each row in the database and compare that with the file names in the folder.
<?php
$servername = "localhost";
$user = "root";
$password = "root";
$dbname = "xxxx";
// Create connection
$conn = mysqli_connect($servername, $user, $password, $dbname);
$query = "SELECT Language1 FROM Table";
$result = mysqli_query($conn, $query);
while($row = mysqli_fetch_array($result))
{
$path = "/file/to/path/English/$Language1";
$Language1 = $row['Language1'];
if (file_exists($path))
{
echo "The file $Language1 exists<br/>";
}
else
{ *
echo "The file $Language1 does not exist<br/>";
}
}
mysqli_close($conn);
?>