Current time: 04-16-2014, 02:53 PM Hello There, Guest! (LoginRegister)

Post Reply 
What's wrong with this script?
04-08-2007, 03:02 PM
Post: #1
What's wrong with this script?
Code:
<?php

print "hello\n";

ini_set ('display errors', 1);
error_reporting (E_ALL);

require_once('../getid3/getid3/getid3.php');

$dir = 'tmp';
$result = scandir ($dir);
arsort($result);
foreach ($result as $file)
{        
rename ("$file", "sermons/$file") or die ("Could not move file");
}
?>
Find all posts by this user
Quote this message in a reply
04-08-2007, 04:30 PM
Post: #2
What's wrong with this script?
Well for starters there is no base directory being specified. For example,
Code:
$dir = 'tmp';

*** should be ***

$dir = realpath('/home/username/tmp');
Cool Atropos | openvein.org
Visit this user's website Find all posts by this user
Quote this message in a reply
04-08-2007, 06:28 PM
Post: #3
What's wrong with this script?
I have a script which scans a direction in a similar fashion, and it is given a relative path just as this one and that script works just fine. What benefit is gained from specifying a base directory?
Find all posts by this user
Quote this message in a reply
04-08-2007, 09:23 PM
Post: #4
What's wrong with this script?
I am thinking the problem maybe because you are lacking the ./ in front of your directory.

You could do something like the following as an alternative.

$dir = './tmp';
$d=opendir($dir);
while (false !== ($file = readdir($d))) {
$files[]=$file;
}
sort ($files);
foreach ($files as $file) {

Silk

My website
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: