473,406 Members | 2,954 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Script Reloading Issue

Tom
I have a PHP framework that integrates buffering and sessions among
other things and I'm having a problem where my script will get reloaded
2 or 3 times before being output to the browser. I haven't found any
other references to this sort of problem so I thought I'd try here.

I do most my development on a Windows XP Pro desktop (running XAMPP),
so I thought maybe it was an XP-specific problem, but I just tried it
on my linux host and same thing. Here's a little log that helps
illustrate:

Session|Script Basename Datetime Split Time
-----------------------------------------------------------------------------------------
001|01 test.php [2006 Jun 13 06:27:00] +-----+ ms
002|01 test.php [2006 Jun 13 06:27:01] +348.15 ms
003|01 test.php [2006 Jun 13 06:27:01] +265.15 ms

That's loading the page in Firefox once. Counters in the left column
are a session and static variable respectively. Other scripts will
load twice. It's especially problematic where there's something like a
email trigger involved as it will send off multiple emails where only 1
is wanted.

Anyone else encounter anything like this? Could it be a Session or
buffering problem? Something to do with logging perhaps? And why 2 or
3 times and not 7 or 8 or 1000? Any insight welcome.

Puzzled,
Tom

Jun 13 '06 #1
4 1396
Tom
I've narrowed my problem a bit. As part of my framework, I set various
head variables (e.g. title, character-encoding, etc.) in an array
($HEAD) and then echo them by calling a function print_html_head($HEAD)
which returns the document declaration and head portion of my web page
as a string.

So far so good. But when I now echo this string, the page reloads
three times. To wit, breakpoint before echo statement, no reload.
After echo statement, page reloads three times. Note also: the output
is buffered, so it's not being output in the browser yet. And this is
the first echo statement in the script.

Anybody have any idea what this would be symptomatic of?

Thanks,
Tom
Tom wrote:
I have a PHP framework that integrates buffering and sessions among
other things and I'm having a problem where my script will get reloaded
2 or 3 times before being output to the browser. I haven't found any
other references to this sort of problem so I thought I'd try here.

I do most my development on a Windows XP Pro desktop (running XAMPP),
so I thought maybe it was an XP-specific problem, but I just tried it
on my linux host and same thing. Here's a little log that helps
illustrate:

Session|Script Basename Datetime Split Time
-----------------------------------------------------------------------------------------
001|01 test.php [2006 Jun 13 06:27:00] +-----+ ms
002|01 test.php [2006 Jun 13 06:27:01] +348.15 ms
003|01 test.php [2006 Jun 13 06:27:01] +265.15 ms

That's loading the page in Firefox once. Counters in the left column
are a session and static variable respectively. Other scripts will
load twice. It's especially problematic where there's something like a
email trigger involved as it will send off multiple emails where only 1
is wanted.

Anyone else encounter anything like this? Could it be a Session or
buffering problem? Something to do with logging perhaps? And why 2 or
3 times and not 7 or 8 or 1000? Any insight welcome.

Puzzled,
Tom


Jun 14 '06 #2
Rik
Tom wrote:
I've narrowed my problem a bit. As part of my framework, I set
various
head variables (e.g. title, character-encoding, etc.) in an array
($HEAD) and then echo them by calling a function
print_html_head($HEAD)
which returns the document declaration and head portion of my web page
as a string.

So far so good. But when I now echo this string, the page reloads
three times. To wit, breakpoint before echo statement, no reload.
After echo statement, page reloads three times. Note also: the output
is buffered, so it's not being output in the browser yet. And this is
the first echo statement in the script.

Anybody have any idea what this would be symptomatic of?


Incorrectly flushing the buffer?
What functions do you use to send the buffer?

Grtz,
--
Rik Wasmus
Jun 14 '06 #3
Tom
I use the following code to flush the buffer as suggested at
http://www.php.net/manual/en/function.ob-end-flush.php:

while (ob_get_level() > 0)
{
ob_end_flush();
}

However, I just noticed a comment:

"Apart from being mostly redundant, ob_end_flush() can be downright
damaging in some weird cases..."

So maybe it has something to do with that.

What I find odd is: if I comment out the echo statement (thus removing
the document statement and head section), the script loads normally. I
thought maybe it was a syntax error, but I've run the XHTML output
through the w3C validator and it validates.

I've also tried removing the buffer flush all together and just letting
the end of the script flush it, but that doesn't seem to solve the
reloading problem.

I'll tinker and tweak further. Anyone else have this problem with
outputing a web page's head section?

Tom

Rik wrote:
Incorrectly flushing the buffer?
What functions do you use to send the buffer?

Grtz,
--
Rik Wasmus


Jun 14 '06 #4
Tom
Just for the record, I think I've resolved this.

The problem seems to be my <HEAD> output function. It contains 2
placeholder statements for links to an external js and css file. If I
didn't pass a value, it would print out something like this:

<link href="" type="text/css" rel="stylesheet" />

These blank href values in these statements were causing my script to
reload (in Firefox, at least).

Anyway, now I know. Hopefully, this will save some trouble someday for
anyone else having this problem.

Tom

Tom wrote:
I've narrowed my problem a bit. As part of my framework, I set various
head variables (e.g. title, character-encoding, etc.) in an array
($HEAD) and then echo them by calling a function print_html_head($HEAD)
which returns the document declaration and head portion of my web page
as a string.

So far so good. But when I now echo this string, the page reloads
three times. To wit, breakpoint before echo statement, no reload.
After echo statement, page reloads three times. Note also: the output
is buffered, so it's not being output in the browser yet. And this is
the first echo statement in the script.

Anybody have any idea what this would be symptomatic of?

Thanks,
Tom
Tom wrote:
I have a PHP framework that integrates buffering and sessions among
other things and I'm having a problem where my script will get reloaded
2 or 3 times before being output to the browser. I haven't found any
other references to this sort of problem so I thought I'd try here.

I do most my development on a Windows XP Pro desktop (running XAMPP),
so I thought maybe it was an XP-specific problem, but I just tried it
on my linux host and same thing. Here's a little log that helps
illustrate:

Session|Script Basename Datetime Split Time
-----------------------------------------------------------------------------------------
001|01 test.php [2006 Jun 13 06:27:00] +-----+ ms
002|01 test.php [2006 Jun 13 06:27:01] +348.15 ms
003|01 test.php [2006 Jun 13 06:27:01] +265.15 ms

That's loading the page in Firefox once. Counters in the left column
are a session and static variable respectively. Other scripts will
load twice. It's especially problematic where there's something like a
email trigger involved as it will send off multiple emails where only 1
is wanted.

Anyone else encounter anything like this? Could it be a Session or
buffering problem? Something to do with logging perhaps? And why 2 or
3 times and not 7 or 8 or 1000? Any insight welcome.

Puzzled,
Tom


Jun 14 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Tim Morrison | last post by:
Is there any easy way to create a change script as illustrated below for all tables within a database? Right now I would have to create a seperate script for each table. I would like to be able...
3
by: MeAgain | last post by:
Hi I have an external website link on my webpage which open like all the link in TARGET frame. since last week the external link vendor put script in his page which refresh and remove my frame....
14
by: Dafydd | last post by:
I have the following Script in my web page reduce to two pages. <script> function details() { document.getElementById('details').style.visibility='visible';...
2
by: Snolly | last post by:
Hi all, Here is my issue. I have a web page (lets call it page1) with an iframe in it that then opens a pop-up window (page2). The pop-up window is used to edit some data that was loaded into...
2
by: pTsy | last post by:
How to enforce ASP.NET page reloading in other words initiate Page_Load call in C#. Thanks
17
by: CES | last post by:
All, I was wondering if their is a way of loading an external script fill from within a script?? <script language="javascript" type="text/javascript"> function test(var){ <script...
1
by: almarc | last post by:
Problem : Stop an "Unonlaod" when then confirmation is false. Is a really good script but i have just one problem. The problem that i have is when i click on a link. The scipt ask "Do you want to...
1
by: tinnews | last post by:
I'm running a python script via the apache ExtFilterDefine directive, it works basically as expected *except* that when I change the script apache/firefox continue to run the old version of the...
5
by: inetquestion | last post by:
I am looking for a web interface for shell commands or shell scripts. Does anyone know of any exexisting php scripts which would solve this requirement? PHP form accepts input from a user, then...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.