I think I am goin about this all wrong
Posted: Thu Aug 08, 2002 7:55 pm
Hello,
I am trying to make a php script to when given a catagory from a web page will index the directory and from the given formats send the data to a mysql database. I have tested and edited extensively and scoured the net for eamples yet unsuccessful. I found this website and alot of people seem to be very helpful. I would apprieicate and help or pointers on how to get this working very much.
<?
//movie indexer
$dbase = mysql_connect("localhost","user","password");
mysql_select_db("family",$dbase);
//get files in the current directory
$handle=opendir('.');
while ($file = readdir($handle)) {
if (substr($file, -3) == "avi" | substr($file, -3) ==
"mpg" | substr($file, -3) == "mov" | substr($file, -3) == "asf") {
$files[] = array(name => $file, size =>
intval(filesize($file)/1024));
}
}
closedir($handle);
sort($files);
//loop through the the files to enter into the database
for ($i = 0; $i <= count($files)-1; $i++) {
$time = date ("mdY-His");
$moviename = "$files";
$filesize = "$size";
$query = "INSERT INTO movies (moviename, filesize,, time, catagory)";
$query .= "VALUES ('$moviename', '$filesize', '$time', '$catagory')";
}
?>
I am trying to make a php script to when given a catagory from a web page will index the directory and from the given formats send the data to a mysql database. I have tested and edited extensively and scoured the net for eamples yet unsuccessful. I found this website and alot of people seem to be very helpful. I would apprieicate and help or pointers on how to get this working very much.
<?
//movie indexer
$dbase = mysql_connect("localhost","user","password");
mysql_select_db("family",$dbase);
//get files in the current directory
$handle=opendir('.');
while ($file = readdir($handle)) {
if (substr($file, -3) == "avi" | substr($file, -3) ==
"mpg" | substr($file, -3) == "mov" | substr($file, -3) == "asf") {
$files[] = array(name => $file, size =>
intval(filesize($file)/1024));
}
}
closedir($handle);
sort($files);
//loop through the the files to enter into the database
for ($i = 0; $i <= count($files)-1; $i++) {
$time = date ("mdY-His");
$moviename = "$files";
$filesize = "$size";
$query = "INSERT INTO movies (moviename, filesize,, time, catagory)";
$query .= "VALUES ('$moviename', '$filesize', '$time', '$catagory')";
}
?>