By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

resetting browser?

P: n/a
Hi...

I'm getting to grips with custom error handling, and am wondering if it is
possible to somehow reset all the content already sent to the browser, and
send some new stuff in its place.

For example, if I'm looping through a database, and I've already written 10
records to the browser, and then an error occurs, is it possible to send a
command to the browser that makes it drop everything it's received thus far,
and then just have it print the output of my custom error handling function
instead? I'm guessing not, because I think only headers can do such things,
and they've already been sent, but it's worth asking!

P.
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.512 / Virus Database: 309 - Release Date: 19/08/2003
Jul 16 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
The Plankmeister wrote:
Hi...

I'm getting to grips with custom error handling, and am wondering if it is
possible to somehow reset all the content already sent to the browser, and
send some new stuff in its place.

For example, if I'm looping through a database, and I've already written 10
records to the browser, and then an error occurs, is it possible to send a
command to the browser that makes it drop everything it's received thus far,
and then just have it print the output of my custom error handling function
instead? I'm guessing not, because I think only headers can do such things,
and they've already been sent, but it's worth asking!


Turn output buffering on. All output goes in the buffer and is output
when your script terminates. You can clear it if you wish before then.
It can hog memory on the server though if there's a lot of output.

http://uk.php.net/manual/en/function.ob-start.php

Jul 16 '05 #2

P: n/a
On Thu, 28 Aug 2003 10:39:21 +0200
"The Plankmeister" <plankmeister_NO_@_SPAM_hotmail.com> wrote:
Hi...

I'm getting to grips with custom error handling, and am wondering if
it is possible to somehow reset all the content already sent to the
browser, and send some new stuff in its place.

<snip>

Not quite "resetting" the browser, but an option:

You may want to try somesort of javascript function.

<?
$error_page = "http://blah.com/error.php";
if($error)
{
print "<script language='JavaScript' type='text/JavaScript'>";
print "<!--\n";
print "window.location =\"$error_page\"";
print "//--></script>";
}
?>
Matt
--
Quispiam Power Computing | "There are two major products that come out
Pendle Hill, Australia | of Berkeley: LSD and UNIX. We don't believe
+61 2 9688 2894 | this to be a coincidence. "
www.quispiam.com | - Jeremy S. Anderson
Jul 16 '05 #3

P: n/a
"The Plankmeister" <plankmeister_NO_@_SPAM_hotmail.com> wrote in message news:<3f***********************@dread15.news.tele. dk>...
Hi...

I'm getting to grips with custom error handling, and am wondering if it is
possible to somehow reset all the content already sent to the browser, and
send some new stuff in its place.

For example, if I'm looping through a database, and I've already written 10
records to the browser, and then an error occurs, is it possible to send a
command to the browser that makes it drop everything it's received thus far,
and then just have it print the output of my custom error handling function
instead? I'm guessing not, because I think only headers can do such things,
and they've already been sent, but it's worth asking!

P.


Your idea of how PHP (or any other language for that matter)
constructs HTML pages and sends them to the client's browser is
entirely wrong. Your PHP script may construct the web page in stages,
but it is only when it is complete that it is sent to the browser.
Just because your code has finished constructing a bit of HTML does
NOT mean that it is already being displayed on the client's device.

You do NOT write directly to the browser, you write to an output file.
It is only when the file is closed that it is sent to the browser.

Tony Marston
http://www.tonymarston.net/
Jul 16 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.