Forum Moderators: coopster
Parse error: syntax error, unexpected $end in /var/www/vhosts/example.com/httpdocs/builder/copy4.php on line 26
FYI Short_open_tags = ON
Could someone please help.
Thanks in advance.
<?
if(isset($_POST['submit'])) {$source = '/var/www/vhosts/$domain/cgi-bin/$cuid';
$dest = '/var/www/vhosts/$domain/cgi-bin/$cuid';
function copy_dir($source, $destination) {
if (is_file($source)) {
$perm = fileperms($source);
copy($source, $destination);
chmod($destination, $perm);
}
if (is_dir($source)) {
$oldmask = umask(0);
mkdir($destination, 0777);
umask($oldmask);
$dir_handle = opendir($source);
while ($files = readdir($dir_handle)) if( $files!= "." && $files!= "..") $file_array[] = $files;
closedir($dir_handle);
}
for($i=0; $i<count($file_array); $i++) {
$file = $file_array[$i];
if ($destination!= "$source/$file") copy_dir("$source/$file", "$destination/$file");
}
}
?>
[edited by: eelixduppy at 1:37 am (utc) on June 22, 2007]
[edit reason] example.com [/edit]
This means that you are missing a closing bracket. Add a closing bracket, }, to the end of the script. That is where it looks like it belongs.
Thanks
**Also make note that $dest = $destination and I have fixed that in my script and added the } at the end of the file, again doesn't pop an error but doesn't do what the script is suppose to do.
[edited by: RogueDogg at 2:06 am (utc) on June 22, 2007]
instead of
copy($source, $destination);
use
if (!copy($source, $destination)) {
echo 'could not copy: ',$source,' to: '$destination;
}
this way you can see if that is actually what is failing and then check you paths as well
if (!copy($source, $destination)) {
//[i]What you suggested I put[/i]
//echo 'could not copy: ',$source ' to: ',$destination;
//[i]What I ended up using[/i]
echo 'could not copy: ' . $source . ' to: ' . $destination;
}
The script runs with no errors but again does not actually work. I'm at a loss, I've had alot of interaction with people and they seem to be at a loss as well... If anyone can help I'd be greatly appreciative.
Thanks in advance....
<?
if(isset($_POST['Submit'])) {$source = '/var/www/vhosts/example.com/cgi-bin/$cuid';
$destination = '/var/www/vhosts/$domain/cgi-bin/$cuid';
copy_dir();
}else{ echo "script failed";
exit;
}
function copy_dir($source, $destination) {
if (is_file($source)) {
//echo $source;
$perm = fileperms($source);
//copy($source, $destination);
if (!copy($source, $destination)) {
echo 'could not copy: ' . $source . ' to: ' . $destination;
}
chmod($destination, $perm);
}
if (is_dir($source)) {
$oldmask = umask(0);
mkdir($destination, 0777);
umask($oldmask);
$dir_handle = opendir($source);
while ($files = readdir($dir_handle)) if( $files!= "." && $files!= "..") $file_array[] = $files;
closedir($dir_handle);
}
for($i=0; $i<count($file_array); $i++) {
$file = $file_array[$i];
if ($destination!= "$source/$file") copy_dir("$source/$file", "$destination/$file");
}
}
?>
K here are the errors:
Warning: Missing argument 1 for copy_dir(), called in /var/www/vhosts/example.com/httpdocs/builder/copy4.php on line 7 and defined in /var/www/vhosts/example.com/httpdocs/builder/copy4.php on line 13
Warning: Missing argument 2 for copy_dir(), called in /var/www/vhosts/example.com/httpdocs/builder/copy4.php on line 7 and defined in /var/www/vhosts/example.com/httpdocs/builder/copy4.php on line 13
Notice: Undefined variable: source in /var/www/vhosts/example.com/httpdocs/builder/copy4.php on line 14
Notice: Undefined variable: source in /var/www/vhosts/example.com/httpdocs/builder/copy4.php on line 24
Notice: Undefined variable: file_array in /var/www/vhosts/example.com/httpdocs/builder/copy4.php on line 32