PHP

liunx

Guest
Hi,

Iam new to PHP...i have installed PHP5.2.5 in my red hat linux, with Apache 1.3, Mysql 5.0.41...I have an existing PHP project... when i run the web application it gives an syntax error.

Parse error: syntax error, unexpected ';', expecting '(' in /usr/local/apache/htdocs/ops/index.php on line 19

Following is the code snippet:

<?php
define('_INC_VALID_133745_', 1);

require_once ("config.php");

require_once( $mosConfig_abs_path_lib . 'common.php' );
session_start();

//$sql = 'ALTER TABLE t_User ADD COLUMN dtExpired INTEGER NOT NULL DEFAULT 0';
//$options['stm_options'] = "";
//DBHelper::execCmd($sql, $options);die;

if (isset($_SESSION['UserID'])) {
Access::checkValidAccess();
}

if (!isset($_SESSION['AL'])) {
session_regenerate_id(true);
$_SESSION['AL'] = Access::AL_GUEST;
}

// Validate refferer
try {
DataInHelper::checkValidSubmit();
} catch (PEAR_Exception $ex) {
SysErrHelper::showError($ex, '_blank');
}

$controller = DataInHelper::getController();
if((isset($_SESSION['UserID']))&&(isset($_SESSION['ForceChange']))&&($_SESSION['ForceChange']!=0)&&(!is_null($controller)))
{
$_SESSION['TMP_AL']=$_SESSION['AL'];
$_SESSION['AL'] = Access::AL_TEMP;
$controller="change_qap";
};
$mode = DataInHelper::getControllerMode();

$_SESSION['SYS_ID'] = $mosConfig_sys_id;

//switch($_GET["job"])
//{
//case 1:
//$sql = "ALTER TABLE t_User ADD COLUMN ForceChange INTEGER NOT NULL DEFAULT 1";//break;
//case 2:
//$sql = "UPDATE t_User SET ForceChange=0";//break;
//case 3:
//$sql = "UPDATE t_User SET ForceChange=1 WHERE SecretA='George Washington'";//break;
//};
//$options['stm_options'] = "";
//$rs = DBHelper::execCmd($sql, $options);
//die;

$exp_frmt = null;
if ($mode!=1) {
require_once( $mosConfig_abs_path_lib . 'common_vw.php' );
require_once( $mosConfig_abs_path_lib . 'export.php' );
$exp_frmt = ExportHelper::getFormat();
}

// home page assign
if (is_null($controller)) {
switch ($_SESSION['AL']) {
case Access::AL_GUEST:
case Access::AL_TEMP:
$controller = 'login';
break;
default:
$controller = 'main';
break;
}
}
FormErrHelper::reverseClearErrorList($controller);
ob_start(); // buffer Header
// Check User security rights to access to the page required
if ($mode!=1 && $exp_frmt != ExportHelper::FT_CSV) {
switch ($exp_frmt) {
case ExportHelper::FT_PRINT:
$wrapper_postfix = '_print';
break;
case ExportHelper::FT_EXCEL:
$wrapper_postfix = '_excel';
break;
default:
$wrapper_postfix = '';
}
require_once ($mosConfig_abs_path_inc . "header$wrapper_postfix.inc");
}
$tmp = Access::getAccessList();

if ($mosConfig_debug && !array_key_exists($controller, $tmp)) {
try {
SysErrHelper::fatal('security_rights', SysErrHelper::TO_SYSTEM);
} catch (PEAR_Exception $ex) {
SysErrHelper::showError($ex, '_blank');
}
} else {
//var_dump (Access::$AccessList);
if ($_SESSION['AL'] & ($tmp[$controller])) {
$headline_postfix = '';

switch ($_SESSION['AL']) {
case Access::AL_ADMIN:
$headline_postfix = '_adm';
break;
case Access::AL_GUEST:
case Access::AL_TEMP :
$headline_postfix = '_guest';
break;
}
if ($mode!=1 && $exp_frmt == ExportHelper::FT_HTML) {
require_once ($mosConfig_abs_path_inc . "topheadline$headline_postfix.inc");
}
try {
if ($mode==1){
Logger::writeUserAction($controller, $mode);
}
if ($controller!='err_page') {
SysErrHelper::clearFatalError();
};

ob_start(); // buffer Page Content
require_once ($mosConfig_abs_path_controller . $controller . (($mode==1)?".prc":".frm"));
ob_flush(); // flush Header
ob_end_flush(); // flush Page Content
if ($mode!=1 && $controller != 'err_page'){
Logger::writeUserAction($controller, $mode);
};
} catch (PEAR_Exception $ex) {
ob_flush(); // flush Header
ob_end_clean(); // clear Page Content
SysErrHelper::showError($ex);
}

if ($mode!=1 && $exp_frmt == ExportHelper::FT_HTML) {
require_once ($mosConfig_abs_path_inc . "bottomheadline$headline_postfix.inc");
}
} else {
if ($_SESSION['AL'] == Access::AL_GUEST || $_SESSION['AL'] == Access::AL_TEMP) {
$qs = DataInHelper::getQS(null, false);
$_SESSION["PrevURL"] = $qs;
header("Location: index.php");
} else {
try {
SysErrHelper::fatal('access_denied', SysErrHelper::TO_USER);
} catch (PEAR_Exception $ex) {
SysErrHelper::showError($ex, '_blank');
}
}
}
}

if ($mode!=1 && $exp_frmt != ExportHelper::FT_CSV) {
require_once ($mosConfig_abs_path_inc . "footer$wrapper_postfix.inc");
}
?>




thanks,

LijuIs AL_GUEST a property or a method of your Access class, if it is a method it should be invoked like this:

Access::AL_GUEST();Actually Iam new to PHP...currently in learning process...I did a search for Access file but dint find anything Access...also i tried
Access::AL_GUEST();

now it gives me an error at try and catch block
Parse error: syntax error, unexpected '{' in /usr/local/apache/htdocs/ops/index.php on line 23

I believe there is something wrong with the PHP Version.

~ lijutry placing your catch block onto its own line

change this
} catch (PEAR_Exception $ex) {

to this:
}
catch (PEAR_Exception $ex) {Still it gives me the same error

Parse error: syntax error, unexpected '{' in /usr/local/apache/htdocs/ops/index.php on line 23Yes I figured it would throw you the error. Your syntax looks ok to me, try commenting out the function calls, you could start with

#DataInHelper::checkValidSubmit();

I know your error reports the issue as being present in index.php, but it doesn't hurt to try.i tried commenting try {
# DataInHelper::checkValidSubmit();
}
catch (PEAR_Exception $ex) {
SysErrHelper::showError($ex, '_blank');
}


but still the same error appearsThis part of your code also looks funky, remove the semicolons after the curly brackets:

if ($controller!='err_page') {
SysErrHelper::clearFatalError();
};

ob_start(); // buffer Page Content
require_once ($mosConfig_abs_path_controller . $controller . (($mode==1)?".prc":".frm"));
ob_flush(); // flush Header
ob_end_flush(); // flush Page Content
if ($mode!=1 && $controller != 'err_page'){
Logger::writeUserAction($controller, $mode);
};Umm can you have a look inside your Access class and check whether AL_GUEST is a function or a variable?

I can't seem to find other particular syntax errors inside index.phpremoved...The error says some syntax mistake near try and catch block...

Parse error: syntax error, unexpected '{' in /usr/local/apache/htdocs/ops/index.php on line 23Ya Access is a Abstract Class and AL_GUESTis a variable
const AL_GUEST = 16;I ran your script through my IDE's code analyzer and I get some warnings stating that your includes are unsafe because they use variables and then some more stating that some of your global variables were used before they were defined, other than that no syntax errors.

Try commenting out the try catch block if you want, but I doubt it would make much of a difference. Errors usually happen one line above the one reported so it is an issue on that line or before that line.sorry about that, so AL_GUEST is a class constant and it was being accessed properly from the start.

I know you were suspicious of your php install. What version is it?Hi..sorry for the delay in response...Iam using PHP 5.2.5..

But when type <?php phpinfo(); ?> in a php file it shows PHP Version 4.4.7 but in command prompt it says:


PHP 5.2.5 (cli) (built: Nov 27 2007 15:52:01)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend TechnologiesAlso can you tell which IDE you are using for PHPAhh you may want to fix that, go with what phpinfo() says. The IDE I use is Zend Studio (<!-- m --><a class="postlink" href="http://www.zend.com/en/products/studio/">http://www.zend.com/en/products/studio/</a><!-- m -->), you can download their free trial. If you click on the microscope icon (the code analyzer) you will see the warnings I mentioned.Yes that is correct...There is no errors in the php files...can you tell me how fix that php version problemSince you are using Red hat why don't you do something like

su
yum update phpand to uninstall the older php version do:
rpm -e (package name i.e. php-4......)

Hope this helps.No dear that wont work...its gives bash yum command not found error..

Is there anyway to remove PHP4. Coz first i installed PHP4, then i thought there might be some version prob so i installed php5 with out removing php4...:)you don't have yum installed, you need to do it manually using rpm commands. This are instructions on how to install php 5 (<!-- m --><a class="postlink" href="http://www.cyberciti.biz/tips/how-to-install-php5-redhat-enterprise-linux4.html">http://www.cyberciti.biz/tips/how-to-in ... inux4.html</a><!-- m -->)i have'nt install via rpm...i extracted the php 4.tar.gz file then did a ./configure and makeHeh rpm and yum would make your life so much easier. As far as getting rid of your old php install, I guess you are going to have to remove it and its dependencies (if any ) manually
 
Back
Top