php error...please help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
deanjones
Forum Newbie
Posts: 3
Joined: Fri May 01, 2009 4:07 am

php error...please help

Post by deanjones »

hi all...
i have a previously written code which is giving following errors in some systems(servers) only.. and some servers it is running fine...code is written in PHP 5.1

Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in c:\wamp\www\gyn_with_pin\blclasses.php on line 15

Fatal error: Cannot instantiate non-existent class: session in c:\wamp\www\gyn_with_pin\pin_index.php on line 4


The code goes like following...(file name 'blclasses.php')

Code: Select all

<?php
include_once("conf.php");
//Global string for current default dimension
$DefaultDimension="";
 
class TDimension
{
    public $m_strName;      //  Name of the dimension.
    public $m_arrValue;     //  Value of the dimension
 
    function __construct($name, $value)
    {
        $this->m_strName = $name;
        $this->m_arrValue = array();
 
        if($name=='Time')
        {
            if(isset($value['year']))
                $this->m_arrValue['year']   = $value['year'];
            if(isset($value['month']))
                $this->m_arrValue['month']  = $value['month'];
            if(isset($value['day']))
                $this->m_arrValue['day']    = $value['day'];
            if(isset($value['hour']))
                $this->m_arrValue['hour']   = $value['hour'];
            if(isset($value['minute']))
                $this->m_arrValue['minute'] = $value['minute'];
        }
 
        if($name=='Victim' || $name=='Attacker')
        {
            if(isset($value['ipaddress']))
                $this->m_arrValue['ipaddress']  = $value['ipaddress'];
        }
 
        if($name=='Signature')
        {
            if(isset($value['rulename']))
                $this->m_arrValue['rulename']   = $value['rulename'];
        }
 
        if($name=='Sensor')
        {
            if(isset($value['name']))
                $this->m_arrValue['name']   = $value['name'];
        }
    }
};
 
class Dimension
{
    public $m_tdInformation;            //  TDimension Object
    public $m_strTableName;             //  Table Name
    public $m_strFieldName;             //  Field Name
    public $m_strColNameInFactTable;    //  Column Name
    public $m_id;
    public $m_arrDescription;
 
    function __construct($tdInfo)
    {
        if(isset($tdInfo))
        {
             $this->m_tdInformation = $tdInfo;
            
            if($tdInfo->m_strName=='Time')
            {
                $this->m_strTableName = 'time'; 
                $this->m_strFieldName = 'time' ;    
                $this->m_strColNameInFactTable = 'time';    
                $this->m_id = 't_id';
            }
   
            if($tdInfo->m_strName=='Victim')
            {
                $this->m_strTableName = 'host'; 
                $this->m_strFieldName = 'ipaddress' ;   
                $this->m_strColNameInFactTable = 'target';  
                $this->m_id = 'h_id';
                $this->m_arrDescription = array('name','location','internal');
            }
   
            if($tdInfo->m_strName=='Attacker')
            {
                $this->m_strTableName = 'host'; 
                $this->m_strFieldName = 'ipaddress' ;   
                $this->m_strColNameInFactTable = 'source';  
                $this->m_id = 'h_id';
                $this->m_arrDescription = array('name','location','internal');
            }
 
            if($tdInfo->m_strName=='Signature')
            {
                $this->m_strTableName = 'rule';
                $this->m_strFieldName = 'rulename'; 
                $this->m_strColNameInFactTable = 'signature';   
                $this->m_id = 'ruleid';
                $this->m_arrDescription = 
                //array('enabled','updatedto','impactid','severityid','description','typeid'); 
                //  Removing 'enabled', 'updatedto', 'description'
                //array('impactid','severityid','typeid');
                array();
            }
    
            if($tdInfo->m_strName=='Sensor')
            {
                $this->m_strTableName = 'sensor';   
                $this->m_strFieldName = 'name' ;    
                $this->m_strColNameInFactTable = 'analyzer';    
                $this->m_id = 'sensorid';
                $this->m_arrDescription = array('ipaddr','listenport','hostname','description');
            }       
        }
    }
};
 //This class is meant to be stored in $_SESSION
//It is required to maintain the state between various pages.
class Session
{
    public $DefaultDimension;
    public $m_arrTDimension;
    public $Type;           //  current view ? pie, bar or table
    public $m_strOrderBy;   //  sorthing field
    public $m_strOrder;     //  descending or ascending
    
    public function __construct()
    {
        if(isset($_SESSION['State']))
        {
            $State = $_SESSION['State'];
            $this->DefaultDimension = $State->DefaultDimension;
            $this->m_arrTDimension  = array();
            $this->Type             = $State->Type;
            $this->m_strOrderBy     = $State->m_strOrderBy;
            $this->m_strOrder       = $State->m_strOrder;
        }
        else
        {
            $this->DefaultDimension = 'Victim';
            $this->m_arrTDimension  = array();
            $this->Type             = 'Table';
            $this->m_strOrderBy     = 'total_alerts';
            $this->m_strOrder       = 'desc';
        }
    }
}; 
and the pin_index.php goes like.....

Code: Select all

<?php
    include_once("blclasses.php");
    session_start();
    $_SESSION['State'] = new Session();
?>
<html>
<body>
<img src="loading_wh.gif">
</body>
</html>
thanking in advance
Last edited by deanjones on Sun May 03, 2009 5:37 am, edited 1 time in total.
Yossarian
Forum Contributor
Posts: 101
Joined: Fri Jun 30, 2006 4:43 am

Re: php error...please help

Post by Yossarian »

Why do your classes last line have a semi-colon ending them?

[line 115 ] } ;

I've never seen that before?

SB

[line 115 ] }
user___
Forum Contributor
Posts: 297
Joined: Tue Dec 05, 2006 3:05 pm

Re: php error...please help

Post by user___ »

Semi-colons are not common in Php, but this is not the bug. deanjones, do you close your bclasses.php with "?>"?
deanjones
Forum Newbie
Posts: 3
Joined: Fri May 01, 2009 4:07 am

Re: php error...please help

Post by deanjones »

thank you for your replies
but...
yeah.. I have closed the php file with ?> tag...
Cirdan
Forum Contributor
Posts: 144
Joined: Sat Nov 01, 2008 3:20 pm

Re: php error...please help

Post by Cirdan »

What is in conf.php? Maybe you are missing a semicolon there.
deanjones
Forum Newbie
Posts: 3
Joined: Fri May 01, 2009 4:07 am

Re: php error...please help

Post by deanjones »

Hi cirden..thank u for the help

but I dint get u..all the parameters are well set there.. which semicolon?
Post Reply