Jump to content

alej469

New Members
  • Posts

    8
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

alej469's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm not sure my hosting provider offers that feature. I was hoping to find a php solution, mabey just a function or simple script which i could customize... Cheers for the help though buddy
  2. Is there a function in php or a way that I can send emails to my websites subscribers at a certain time once each day? I'm trying to create a 'subscribe to updates' feature, but updates are automatic so I need the emails to be automatic too. I've searched through all the functions of php for something which might help, but havn't found anything... Thanks for any help...
  3. Just a quick one: I'm a complete novice with unix timestamps. How could I display the time a user registered in minutes (from a unix timestamp) for users that registered less than an hour ago? I'm basically hoping to do a YouTube style thing like you get on the comments, which displays the number of seconds ago the comment was made if it was under a minute ago, the number of minutes it was made if it was under a hour ago etc... Is this going to be complicated? Cheers for any help!
  4. foreach ($result as $key => $filename) { if (file_exists($filename)) { unlink($filename); } } ^ That's the code i needed, thanks dwees
  5. I've used print_r and checked that the files listed in the new array are not listed in the database, so the new array is displaying the files that I need to delete, I just need to know how to delete files in an array, as I'm not 100% confident. The array outputs: Array ( [2] => fileone.mp3 [7] => filetwo.mp3 [8] => filethree.mp3 ) + 2997 others! How would i use unlink to delete these files?
  6. Lol, missed out the code: <?php //get path of directory containing this script $dir = $_SERVER['DOCUMENT_ROOT'].dirname($PHP_SELF); //open a handle to the directory $handle = opendir($dir); //intitialize our counter $count = 0; $alldirfiles = array("TEST", "TEST2"); $alldbfiles = array("TEST", "TEST2"); //loop through the directory while (false !== ($file = readdir($handle))) { //evaluate each entry, removing the . & .. entries if (is_file($file) && $file !== '.' && $file !== '..') { $count++; array_push($alldirfiles, $file); } } ///////////////////////////////////////////////////////// mysql_connect("host","name","pass"); @mysql_select_db("thisdb") or die( "Unable to select database"); $query222="SELECT * FROM table ORDER BY id ASC"; $result222=mysql_query($query222); $num222=mysql_numrows($result222); mysql_close(); $i=0; while ($i < $num222) { $rfilename = mysql_result($result222,$i,"filename"); array_push($alldbfiles, $rfilename); $i++; } $result = array_diff($alldirfiles, $alldbfiles); $resultminus = count($result); echo "Total files: ".$count."<br>"; echo "Database files: ".$num222."<br>"; echo "To be deleted files: ".$resultminus."<br>"; print_r($result); ?>
  7. Hey everyone, been trying to solve this problem myself for a while now, but to no avail... I've got a directory full of about 11,000 mp3 files. Most files are in a database which I started using a couple of years ago, the rest are redundant. I'm looking for a way to delete any files which are not listed in the database. I've made some progress with the coding for this, but as you can imagine I'm on edge because any mistakes could be catastrophic! What the code below basically does is put all files in the directory in one array, and all the files in the database in another array. I've then used array_diff to calculate the difference and show the files which are not in the database. What I'm now trying to do is delete all the files in the array ($result). Can anyone help me finish the code for this? Cheers in advance
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.