I'm trying to get a php script to run in a directory using ssh terminal. When I try to run the script, I get the error:
(uiserver):USER:~/directory/folder > php zipper.php
X-Powered-By: PHP/4.4.9
Content-type: text/html
<br />
<b>Parse error</b>: syntax error, unexpected ')', expecting '(' in <b>/BLA/htdocs/directory/folder/zipper.php</b> on line <b>7</b><br />
Oddly enough though, when I insert a little html and visit the page where this script is located, it works fine. That, however, is no help to me as I need to run this with cron.
Here is the script I'm trying to run:
<?php
//date variable
$today = date("Ymd");
//create an instance of ZipArchive class
$zip = new ZipArchive();
//create the archive called images.zip and open it
$result = $zip->open('images.zip', ZipArchive::CREATE);
if ($result) {
//open the directory with the files that need to be archived
$d = dir("turbo/");
//loop through the files in $d
while (false !== ($entry = $d->read())) {
//use a regular expression with preg_match to get just the jpgs
if(preg_match("/\w*\.jpg/",$entry)) {
//add the file to the archive
$zip->addFile("turbo/".$entry,$entry);
}
}
//close the directory and archive
$d->close();
$zip->close();
} else {
//display the error
echo "Failed: $result.\n";
}
//deletes all jpg files
//foreach(glob('/www/images/*.jpg') as $file){
// if(is_file($file))
// @unlink($file);
//}
?>
Here's the line where it's erroring out on:
$result = $zip->open('images.zip', ZipArchive::CREATE);
I'm using 1and1 (I know) as my host, I've tried creating an .htaccess file to force php5, but that doesn't work.
I'm wondering what, syntactically, is wrong with this script? All I want to do is zip all the jpg images in a directory.
Any, ANY, help would be greatly appreciated.