Hello All
Im struck while making a grabber script ... i want to grab songs from a site so i have made a script to fetch the songs path store them in database ..
and then download them using those paths ..
But my script stops after downloading a single song ...
Below is my code ... Please Help ..
require_once("config.php"); // my database connection file
$sql_cat_sng="Select * from categories";
$query_cat_sng=mysql_query($sql_cat_sng);
while ($result_cat_sng=mysql_fetch_array($query_cat_sng)){
$sql_alb_sng="Select * from albums where catid='".$result_cat_sng[id]."'";
$query_alb_sng=mysql_query($sql_alb_sng);
while ($result_alb_sng=mysql_fetch_array($query_alb_sng)) {
$sql_cnt_songs="Select * from songs where catid='2' and albumid='1'";
$query_cnt_songs=mysql_query($sql_cnt_songs);
$row_cnt_songs=mysql_num_rows($query_cnt_songs);
$songs_cnt=1;
while ($songs_cnt<=$row_cnt_songs){
$sql_songs="select * from songs where catid='2' and albumid='1' and status='0'";
$query_songs=mysql_query($sql_songs);
while ($result_songs=mysql_fetch_array($query_songs)){
$filename =$result_songs[song_path];
header("Location: $filename");
$sql_update_sng_sts="UPDATE `songs` SET `status` = '1' WHERE `id` =$result_songs[id] ";
$query_update_sng_sts=mysql_query($sql_update_sng_sts);
}
$songs_cnt++;
}
$dir = "C:\Documents and Settings\admin\Desktop\songss";
$dh = opendir($dir);
while (($file = readdir($dh)) !== false) {
//echo "<A HREF=\"$file\">$file</A><BR>\n";
if (($file!=".") || ($file!="..")){
$new_file=$file;
$old_dest="C:/Documents and Settings/admin/Desktop/songss/$file";
$cat_name=$result_cat_sng['name'];
$album_name=$result_alb_sng['album'];
$path=$cat_name."/".$album_name;
mkdir($path,777);
$new_dest="C:/Documents and Settings/admin/Desktop/$path/$new_file";
copy($old_dest,$new_dest);
unlink($old_dest);
}
}
closedir($dh);
}
}
Please Help ...
Warm Regards
tarun...@gmail.com
(Tarun Aggarwal)