473,408 Members | 1,821 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,408 software developers and data experts.

ob_start, timeouts with output_callback function

hi,

I am using output buffering with ob_start and a callback function, which
replaces variables like "%var%" with the equivilants taken out of a
mysql database. This works well! But I get sometimes php timeouts (max
execution time (30s) exceeded ...). The Server should be really fast
enough (dual PIII, >1 GB RAM) and runs with PHP 4.1.2 and MySQL 3.23.56.

Any suggestions? Known Probs?!

I am still trying to find a solution by my self ( and an error in my
script) ... but hopefully someone can give me a hint ...
cu :: cal

full code:

// ---------------------------------------------
// replace all internal vars (%..%) in string
// ---------------------------------------------
function html_replacevars($tmp) // input urldecoded
{
global $mysql;
db_connect();
// replace all %*% in value
for ($i=0;$i<2;$i++) // twice because of recursive use of %*%
{
$result = db_result("Select * FROM $mysql[settings] WHERE
variable LIKE '\%%'");
while ($row = mysql_fetch_array($result))
{
$rvar = urldecode($row[variable]); // %var%
$rval = urldecode($row[value]); // realvalue
$tmp = str_replace($rvar, $rval, $tmp);
}
}
@mysql_close();
return $tmp; // output urldecoded
}


ob_start("html_replacevars")

[..]
output
[..]

ob_end_flush();

Jul 16 '05 #1
1 3803

okay ... I tried the following:
// ---------------------------------------------
// replace all internal vars (%..%) in string
// ---------------------------------------------
function html_replacevars($input) // input urldecoded
{
global $mysql;
db_connect();
$tmp = $input; // this prevents timeouts ...
strange, but works!
// replace all %*% in value
for ($i=0;$i<2;$i++)
{
$result = db_result("Select * FROM $mysql[settings] WHERE
variable LIKE '\%%'");
while ($row = mysql_fetch_array($result))
{
$rvar = urldecode($row[variable]);
$rval = urldecode($row[value]);
$tmp = str_replace($rvar, $rval, $tmp);
}
}
@mysql_close();
return $tmp; // output urldecoded
}
by using a replacement variable $input to $tmp it works fast and stable.
I've read this hint in a user comment in the php manual.

Christian Luszick wrote:
hi,

I am using output buffering with ob_start and a callback function, which
replaces variables like "%var%" with the equivilants taken out of a
mysql database. This works well! But I get sometimes php timeouts (max
execution time (30s) exceeded ...). The Server should be really fast
enough (dual PIII, >1 GB RAM) and runs with PHP 4.1.2 and MySQL 3.23.56.

Any suggestions? Known Probs?!

I am still trying to find a solution by my self ( and an error in my
script) ... but hopefully someone can give me a hint ...
cu :: cal

full code:

// ---------------------------------------------
// replace all internal vars (%..%) in string
// ---------------------------------------------
function html_replacevars($tmp) // input urldecoded
{
global $mysql;
db_connect();
// replace all %*% in value
for ($i=0;$i<2;$i++) // twice because of recursive use of %*%
{
$result = db_result("Select * FROM $mysql[settings] WHERE variable
LIKE '\%%'");
while ($row = mysql_fetch_array($result))
{
$rvar = urldecode($row[variable]); // %var%
$rval = urldecode($row[value]); // realvalue
$tmp = str_replace($rvar, $rval, $tmp);
}
}
@mysql_close();
return $tmp; // output urldecoded
}


ob_start("html_replacevars")

[..]
output
[..]

ob_end_flush();


Jul 16 '05 #2

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

Similar topics

0
by: Phil Powell | last post by:
Based upon the following articles: http://www.experts-exchange.com/Web/Web_Languages/PHP/Q_20708448.html http://www.experts-exchange.com/Web/Web_Languages/PHP/Q_20717295.html...
0
by: Phil Powell | last post by:
I traced the problem to what I believe is when I use the included content library script into the viewinterns.php page. This script will repeatedly instantiate a DateGroupHTMLGenerator class...
2
by: Martin | last post by:
hi, i want to use a callback function for my ob_start inside of a class. but it wont work in any way. ob_start("bar") works fine if the function is not in a class. ob_start("$foo->bar") or...
4
by: zmcelrath87 | last post by:
I am having a problem involving the scope of timeouts and intervals. Since timeouts and intervals execute in the global scope, dynamically generated local interval/timeout declarations do not work,...
12
by: ORC | last post by:
Shouldn't 'ReadFile' block when timeouts are specified even when running in overlapped mode or am I wrong ??? Thanks Ole
2
by: mircu | last post by:
Hi, I need a quick solution to make my application behave correctly when one of these timeouts occurs. I have some logic in session_start but when the authentication cookie timeouts the user is...
0
by: Thomas Mlynarczyk | last post by:
Hi, I want to process the output of a script line by line before sending it out. I thought, ob_start() with a callback function would do the job if the callback function was called for every...
2
by: Joannes Vermorel | last post by:
We have developed an open-source eCommerce sales forecasting add-on in PHP (see link below) that requires usually more than a few seconds to complete because the process involves some Web Services...
4
by: Giampaolo Rodola' | last post by:
Hi, I'm trying to implement an asynchronous scheduler for asyncore to call functions at a later time without blocking the main loop. The logic behind it consists in: - adding the scheduled...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.