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 6472011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:17:30+00:00 2026-05-25T06:17:30+00:00

I am getting a really frustrating problem with my php script below. Everything works

  • 0

I am getting a really frustrating problem with my php script below. Everything works as expected on my local machine using XAMPP, but when I put it on the web I get:

Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /homepages/38/d220091779/htdocs/roughgiraffed/RG2/portfolio_item_vars.php on line 20

I would greatly appreciate it if someone would take a quick look for me, or offer some advice.

The error is on the line directly below array_push($projectImages, $filePath); near the bottom of the function.

EDIT: Even though the error is listed as being on line 20 (in getImages()) I removed the class below and the error went away. Of course, I still want the class to work… but does this mean it is a problem with my php version after all?

<?php

$pageTitle = "Portfolio";

//return an array of the (non-featured, non-thumb) images within a given project
function getImages($category, $project){
    $projectImages = Array();
    if ($dir = opendir("portfolio/" . $category . "/" . $project . "/")){
        //open each 'file' in the directory
        while($file = readdir($dir)){
            $filePath = "portfolio/" . $category.'/'.$project.'/'.$file;
            //check if it really is a file
            if($file != "." && $file != ".." && $file[0] != '.' && is_file($filePath)) {
                //check if it is an image
                if(getimagesize($filePath)){
                    //ignore featured_image and _thumbs
                    if(!strstr($file, "featured_image") && !strstr($file, "_thumb")){
                        //Add the non-featured, non-thumb image to the array
                        array_push($projectImages, $filePath);
                    }
                }
            }
        }
        closedir($dir);   
    }
    return $projectImages;
}

class ImgResizer {
    private $originalFile = '';
    public function __construct($originalFile = '') {
        $this -> originalFile = $originalFile;
    }
    public function resize($newWidth, $targetFile) {
        if (empty($newWidth) || empty($targetFile)) {
            return false;
        }
        $src = imagecreatefromjpeg($this -> originalFile);
        list($width, $height) = getimagesize($this -> originalFile);
        $newHeight = ($height / $width) * $newWidth;
        $tmp = imagecreatetruecolor($newWidth, $newHeight);
        imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height);
        if (file_exists($targetFile)) {
            unlink($targetFile);
        }
        imagejpeg($tmp, $targetFile, 85); // 85 is my choice, make it between 0 – 100 for output image quality with 100 being the most luxurious
    }
}

?>

My Localhost is running PHP Version 5.3.1

The WebHost is running PHP Version 4.4.9

  • 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-05-25T06:17:31+00:00Added an answer on May 25, 2026 at 6:17 am

    This weird kind of parse errors may happen in PHP4 if you use PHP5 specific things, like the public keyword, which was introduced with PHP5.

    You maybe should have a look at the official PHP5 backward incompatibilties list when planning to run the very same source code under PHP4 and PHP5.

    Excerpt:

    Backward Incompatible Changes

    Although most existing PHP 4 code should work without changes, you
    should pay attention to the following backward incompatible changes:

    • There are some new reserved keywords.
    • strrpos() and strripos() now use the entire string as a needle.
    • Illegal use of string offsets causes E_ERROR instead of E_WARNING.

    :

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is getting really frustrating now! I've created a script that appends some content
I'm using a state machine, and the code's getting really verbose when testing against
I'm using Compact Framework 3.5 / VS2008. I'm getting really odd behavior with TypeLoadException.
I'mm getting really long client ids one such example is below. Some of them
I am using Firebird, but lately the database grows really seriously. There is really
I am using Entity Framwwork and Code First and getting really confused. I have
I'm getting a really frustrating error that I've been struggling with for some time
So I'm getting really sick of E*TRADE and, being a developer, would love to
[Meta-note:] I was browsing the question page, getting really tired of DIVS vs Tables
Not really getting the point of the map function. Can anyone explain with examples

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.