hi,
i put a script together to scan a directory and its subdirectories for
all mp3 files. the tag informations and path then should be put into a
mysql database.
i included a script called mphp3.php from http://res.crea-bmb.de/mphp3/
which returns the needed tag info from one file.
the script to recursively scan a dir i got from groups.google.
using the mphp3.php with one file is simple (demo from website):
<?
include("mphp3.php");
$info = New mphp3(2);
$info->load("test.mp3");
echo $info->title." is a nice song. it's encoded with".$info->
bitrate."kbps.";
?>
my code to include the db:
<?
include("mphp3.php");
mysql_connect("192.168.100.12","user","password") or die ("no connect
to db");
mysql_select_db("music") or die ("db does not exist");
function scan_dir($dir)
{
$info = New mphp3(2);
$handle = @opendir($dir);
while ($file = @readdir ($handle))
{
if (eregi("^\.{1,2}$",$file))
{
continue;
}
if(is_dir($dir.$file))
{
scan_dir($dir.$file."/");
}
else
{
$info->load("/".$dir.$file);
$query ="insert into mp3 (
file,
path,
artist,
title,
album)
values (
'$info2->filename',
'$dir',
'$info2->v2_artist',
'$info2->v2_title',
'$info2->v2_album');";
mysql_query($query);
}
}
@closedir($handle);
}
scan_dir("mp3/");
?>
but all it does is to put the path ($dir) into the database. everything
else is ignored. an error does not occur. since the simple demo works
fine i think its a problem with the validity of variables.
i'm new to php, so could anybody give me a hint on what mightbe wrong
with my code please?
thanx a lot
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php