Hello,
I have a strange error, I think. When using frames with PHP include HTML documents, on the server the frame-document-PHP-code is run more then once and session_objects are sometimes missing and again created.
We are using PHP version 4.0.3 on a Linux Red Hat environment.
The description. First I have a index.php with two frames; topframe.php and workframe.php. At the start of each of these three PHP-scripts I put a include of general.php. In this code I do a session_start() so that I can use session global variables in the three php-scripts.
When I set (session_register) a variable in index.php, I want to use this in topframe.php and workframe.php. But what happens; sometimes the registered variable is NOT there. Also by a refresh of the webpage, the index.php is called one time, but the two frame code two times!?
I can ONLY see this behavior when i put database logging in the general.php code; on screen (in browser) you don't see the second calls.
Below this message I have put the code listings and logging in database.
I hope someone can see what is going wrong.
Regards,
Gerald
Code listings;
bugindex.php:
<?php $BIlog_module='index.php'; require("bugging1.php"); ?>
<head>
</head>
<frameset rows="95,*" frameborder="NO" border="0" framespacing="0">
<frame name="topFrame" scrolling="NO" noresize src="topframe.php" >
<frame name="workFrame" noresize src="workframe.php">
</frameset>
<noframes><body bgcolor="#FFFFFF">
Your browser doesn't support FRAMES.<BR>
</body></noframes>
topframe.php;
<?php $BIlog_module="top.php"; require("bugging1.php"); ?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="expires" CONTENT="31 dec 1999">
</head>
<body bgcolor="#6699FF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<BR>
TOP FRAME WINDOW (DOCUMENT) OBJECT
<BR>
</body>
workframe.php;
<?php $BIlog_module='helpinfoWin.php'; require("bugging1.php"); ?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFCC">
<BR>
WORKFRAME WINDOW (DOCUMENT) OBJECT
<BR>
</body>
PHP general code; BUGGING1.PGP;
<?PHP
session_start();
// set access
$hostname= (not shown)
$username= (not shown)
$password= (not shown)
$databasename= (not shown)
// Try access database
if (!($link=mysql_pconnect($hostname,$username,$password))) {
printf("Error connecting to host %s, by user %s",$hostname,$username);
exit(); }
// Select the database
if (!mysql_select_db($databasename,$link)) {
printf("Error selecting %s",$databasename);
exit(); }
if (session_is_registered("BIloggingcnt")) {
$logmessage="I-Use registered session object";
session_unregister("BIloggingcnt"); }
else {
$logmessage="I-Create new session object";
$BIloggingcnt=0; }
if (empty($BIlog_module)) { $BIlog_module="(not set)"; }
$BIloggingcnt=$BIloggingcnt + 1;
session_register("BIloggingcnt");
$timestamp=date("YmdHis",time());
$result=mysql_query("INSERT INTO logging (message,timestamp,module,sessionlogcnt) VALUES ('$logmessage','$timestamp','$BIlog_module',$BIloggingcnt)");
if (!($result)) { printf("E-Can not log messages in Logging table...<BR>%s",mysql_error()); }
?>
Database logging:
id message timestamp module sessionlogcnt
1 I-Create new session object 20001027145134 index.php 1 Edit Delete
2 I-Use registered session object 20001027145134 helpinfoWin.php 2 Edit Delete
3 I-Use registered session object 20001027145134 top.php 3 Edit Delete
4 I-Use registered session object 20001027145134 top.php 4 Edit Delete
5 I-Use registered session object 20001027145134 helpinfoWin.php 5 Edit Delete
6 I-Use registered session object 20001027145146 index.php 6 Edit Delete
7 I-Create new session object 20001027145146 top.php 1 Edit Delete
8 I-Create new session object 20001027145146 helpinfoWin.php 1 Edit Delete
9 I-Use registered session object 20001027145146 top.php 7 Edit Delete
10 I-Use registered session object 20001027145146 helpinfoWin.php 8 Edit Delete
11 I-Use registered session object 20001027150740 index.php 9 Edit Delete
12 I-Create new session object 20001027150740 helpinfoWin.php 1 Edit Delete
13 I-Create new session object 20001027150740 top.php 1 Edit Delete
14 I-Use registered session object 20001027150740 top.php 10 Edit Delete
15 I-Use registered session object 20001027150740 helpinfoWin.php 11 Edit Delete
(the above logging is from first calling bugindex.php and then two times refreshing the browser window).