1. Loop through my audio folder which contains the following four files:
I'll Be Right Here.mp3
Time Marches On.mp3
Where Did It Go (Our Love).mp3
You're Still The One.mp3
2. Check for .mp3 file extension
3. Query table to see if the file name as string exists in my table(the audio table is empty)
_If not then insert the file name into the table.
Here is my code:
Code: Select all
<?php
include("connect.php");
if ($handle = opendir("audio")) {
while (false !== ($file = readdir($handle))) {
$checker = end(explode('.', $file));
if($checker=='mp3'){
Update($file);
}
}
closedir($handle);
}
function Update($audio){
$result = mysql_query("SELECT * FROM audio WHERE name = '$audio'");
if(!$result){
echo $audio."</br>";
//mysql_query("INSERT INTO audio (name) VALUES ('$audio')");
}
}
?>I'll Be Right Here.mp3
You're Still The One.mp3
If anyone can help me understand why the other 2 strings are not being echoed I would appreciate it.