I am having the following error; please help me;

Parse error: syntax error, unexpected '=', expecting '(' in /system/myclientbase/libraries/MY_Router.php on line 7

Line 7 is highlighted below

<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

/ load the modules class /
require_once 'Modules'.EXT;

/ define the module locations and offset /
Modules::$locations = array (
APPPATH.'modules_core/' => '../modules_core/',
APPPATH.'modules_custom/' => '../modules_custom/',
);

/
Modular Extensions - PHP5

Adapted from the CodeIgniter Core Classes
@ http://codeigniter.com

Description:
This library extends the CodeIgniter router class.

Install this file as application/libraries/MY_Router.php

@copyright Copyright (c) Wiredesignz 2010-01-18
@version 5.2.31

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
/
class MY_Router extends CI_Router
{
private $module;

public function fetch_module() {
	return $this->module;
}

public function _validate_request($segments) {

	/* locate module controller */
	if ($located = $this->locate($segments)) return $located;

	/* use a default 404 controller */
	if (isset($this->routes['404']) AND $segments = explode('/', $this->routes['404'])) {
		if ($located = $this->locate($segments)) return $located;
	}

	/* no controller found */
	show_404();
}

/** Locate the controller **/
public function locate($segments) {

	$this->module = '';
	$this->directory = '';
	$ext = $this->config->item('controller_suffix').EXT;

	/* use module route if available */
	if (isset($segments[0]) AND $routes = Modules::parse_routes($segments[0], implode('/', $segments))) {
		$segments = $routes;
	}

	/* get the segments array elements */
	list($module, $directory, $controller) = array_pad($segments, 3, NULL);

	foreach (Modules::$locations as $location => $offset) {

		/* module exists? */
		if (is_dir($source = $location.$module.'/controllers/')) {

			$this->module = $module;
			$this->directory = $offset.$module.'/controllers/';

			/* module sub-controller exists? */
			if($directory AND is_file($source.$directory.$ext)) {
				return array_slice($segments, 1);
			}

			/* module sub-directory exists? */
			if($directory AND is_dir($module_subdir = $source.$directory.'/')) {

				$this->directory .= $directory.'/';

				/* module sub-directory controller exists? */
				if(is_file($module_subdir.$directory.$ext)) {
					return array_slice($segments, 1);
				}

				/* module sub-directory sub-controller exists? */
				if($controller AND is_file($module_subdir.$controller.$ext))	{
					return array_slice($segments, 2);
				}
			}

			/* module controller exists? */
			if(is_file($source.$module.$ext)) {
				return $segments;
			}
		}
	}

	/* application controller exists? */
	if(is_file(APPPATH.'controllers/'.$module.$ext)) {
		return $segments;
	}

	/* application sub-directory controller exists? */
	if(is_file(APPPATH.'controllers/'.$module.'/'.$directory.$ext)) {
		$this->directory = $module.'/';
		return array_slice($segments, 1);
	}
}

public function set_class($class) {
	$this->class = $class.$this->config->item('controller_suffix');
}

}

    Which version of PHP are you using? If the answer is PHP 4, you might want to look into upgrading to PHP 5 right away - PHP 4 is severely outdated and lacking a lot of functionality as compared to PHP 5 (especially in the OOP area)... and that's not to mention the fact that it isn't even being patched for security vulnerabilities anymore either...

      Perl, Python, PHP4, PHP5, PHP6 (beta) is supported in my hosting.

        I doubt your host supports PHP 6, since there is no such thing right now :p, but that's besides the point - what does matter is what you're using right now, not what you could be using.

        If, for example, you were executing the above script under PHP 4 instead of 5, your error probably makes sense. On PHP 5, I got a different parse error message caused by a missing ':' on line #74 (you've got a single ':' instead of the double colon '::').

          I dont know but thats what is displayed on the site?

          I am a novice hence can you tell me what to do i.e. with the error?

          Parse error: syntax error, unexpected '=', expecting '('

            sm31live wrote:

            I am a novice hence can you tell me what to do i.e. with the error?

            That's what I've been trying to tell you all along - use PHP 5 instead of PHP 4 (and also fix the real parse error I mentioned above).

              created a .htaccess file and it works.

              Thanks

                Write a Reply...