Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8533997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T10:05:37+00:00 2026-06-11T10:05:37+00:00

I’m trying to get a php script to run in a directory using ssh

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T10:05:39+00:00Added an answer on June 11, 2026 at 10:05 am

    It seems this method won’t work in PHP 4 (The manual mentions (PHP 5 >= 5.2.0)).

    I tried running your code in a PHP 4 sandbox, I got the same output as you did.
    When you select PHP 5.2.15 and run the code, everything works fine (except that the site mentions having open() disabled for security reasons).

    So it seems you’re out of luck. I recommend having a look at the File_Archive package mentioned in this Stackoverflow post. According to their site, it will run on PHP 4.3.3

    Dependencies for File_Archive

    PHP 4.3.3
    PEAR Installer 1.4.0b1
    MIME_Type
    pcre extension
    zlib extension
    Mail_Mime (Optional)
    Mail (Optional)
    Cache_Lite 1.5.0 (Optional)
    bz2 extension (Optional)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm trying to create an if statement in PHP that prevents a single post
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.