session in class problem

From: Date: Thu, 20 Jun 2002 23:40:48 +0000
Subject: session in class problem
Groups: php.general 
Request: Send a blank email to php-general+get-103219@lists.php.net to get a copy of this message
Try enclosing the function code in brackets: function Check_Session() { code goes here } Mick Quoting Mark Colvin <mark.colvin@ccmltd.co.uk>: > I have the following .php script and .inc file which doesn't work: > > ===== .php file ===== > > <?PHP > // Include function files > require_once "includefiles/session_functions.inc"; > > // Create instances of the required class > $sess = new Sessions; > > // chech for valid session > $sess->Check_Session(); > > phpinfo(); > ?> > > <html> > <head> > <title>Untitled</title> > </head> > <body> > <table summary=""> > <tr><td>admin</td></tr> > </table> > </body> > </html> > > > ===== .inc file ===== > > <?PHP > class Sessions > { > > function Check_Session() > > session_start(); > if (!session_is_registered("SESSION")) > { > header("Location: > http://???.???.??.?/index.php?logintext=Please > login."); > exit(); > } > > } > > The session was created in a previous login script. When I enter the > .php > script I get the following error: > > Parse error: parse error, expecting `'{'' in > /var/www/html/includefiles/session_functions.inc on line 7 > > Fatal error: Cannot instantiate non-existent class: sessions in > /var/www/html/adminoutput.php on line 8 > However, if I copy the code from the function in the .inc file and place > it > at the top of my php script, and delete the class code in the php > script > everything works OK. Why is this happening? I also tried placing > session_start() in the php script before calling the class method > Check_Session but this had no effect. > > Thanks in advance > > > Mark

« previous php.general (#103219) next »