Hey Guys,
I want to be able to upload a large amount of mp3's to a private area on our website and have a script that will scan the folder for all the filenames and then create a record in the db of all the filenames. It is to help with creating the playlist for my friends radio show. To manually insert all the filenames each month woudl be a nightmare!
I have been messing with a partial script I found on the web, and it kind of does something but not what I want it to.
heres the db
id int(4)
title varchar(250)
mp3 varchar(250)
sort int(4)
visible int(1)
added datetime
heres the script i am trying to use:
<?
$listDir = array();
$dir = "./music";
if($handler = opendir($dir)) {
while (($sub = readdir($handler)) !== FALSE) {
if ($sub != "." && $sub != ".." && $sub !=
"Thumb.db") {
if(is_file($dir."/".$sub)) {
$listDir[] = $sub;
}elseif(is_dir($dir."/".$sub)){
$listDir[$sub] = $this->ReadFolderDirectory($dir."/".$sub);
}
}
}
closedir($handler);
}
$db = mysql_connect("localhost","gfab_ml","xxxxxxx");
mysql_select_db("gfab_ml",$db);
$colors=serialize($listDir); //takes the data from a post
$sql="INSERT INTO ml_music (ID, title, added)
VALUES('','$colors','')";
$result = mysql_query($sql) or die (mysql_error());
?>
it does insert the values into the db but what it does is creates 1 record and spits all the results in a really weird way like this. into the title field.
a:18:{i:0;s:23:"14 Mr Magic Premier.mp3";i:1;s:23:"track1.mp3";i:2;s:15:"track2.jpg";i:3;s:15:"track3.fxp";i:4;s:12:"track4.mp3";i:5;s:7:"track5.mp3";i:6;s:7:"track6.jpg";i:7;s:7:"track7.mp3";i:8;s:12:"track8.mp3"
Could anyone please help me to make it work? im a bit of a noob. but i do like to tinker!