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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:40:13+00:00 2026-06-06T20:40:13+00:00

I am recieveing the following parse error: Parse error: syntax error, unexpected ‘(‘, expecting

  • 0

I am recieveing the following parse error:

Parse error: syntax error, unexpected ‘(‘, expecting ‘,’ or ‘;’ in
H:\Programs\USBWebserver
v8.5\8.5\root\oopforum\func\register.class.php on line 7

which relates to the following line of code in my class:

private $random_name = rand(1000,9999).rand(1000,9999).rand(1000,9999).rand(1000,9999);

I can not see why this line of code would cause a parse error?

Here is some surrounding code:

class register{
    public $post_data = array();
        private $dbh;
        private $allowed_type = array('image/jpeg','image/png','image/gif');
        private $random_name = rand(1000,9999).rand(1000,9999).rand(1000,9999).rand(1000,9999);
        private $path = 'img/thumb_/'.$random_name. $_FILES['file']['name'];
        private $max_width = 4040;
        private $max_height = 4040;
        private $max_size = 5242880;
        private $temp_dir = $_FILES['file']['tmp_name'];
        private $image_type = $_FILES['file']['type'];
        private $image_size = $_FILES['file']['size'];
        private $image_name = $_FILES['file']['name'];
        private $image_dimensions = getimagesize($temp_dir);
        private $image_width = $image_dimensions[0]; // Image width
        private $image_height = $image_dimensions[1]; // Image height
        private $error = array();

        public function __construct($post_data, PDO $dbh){
        $this->post_data = array_map('trim', $post_data);
        $this->dbh = $dbh;
        }
}

What is causing the parse error?

  • 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-06T20:40:14+00:00Added an answer on June 6, 2026 at 8:40 pm

    You can’t initialize member variables to anything that is not static, and you’re trying to call a function.

    From the manual:

    This declaration may include an initialization, but this
    initialization must be a constant value–that is, it must be able to
    be evaluated at compile time and must not depend on run-time
    information in order to be evaluated.

    The workaround is to set your variable in the constructor:

    private $random_name;
    public function __construct() { 
        $this->random_name = rand(1000,9999).rand(1000,9999).rand(1000,9999).rand(1000,9999);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My Jquery code is recieving following error: Uncaught SyntaxError: Unexpected token ; Here is
I'm recieving the following error on trying to run an append query in access.
Background I'm receiving the following error when trying to render a partial view in
I am receiving the following error in PHP Notice undefined offset 1: in C:\wamp\www\includes\imdbgrabber.php
I am receiving the following error in my code (c#, .Net 3.5, VS2008) when
I am receiving the following error when I try to send mail using a
I seem to be intermittently receiving the following error: BigQuery error in query operation:
I'm trying to implement my own GenericIdentity implementation but keep receiving the following error
I'm recieving the following error message, A public action method 'RenderMenu' was not found
The error that I am receiving is the following: Traceback (most recent call last):

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.