Page 1 of 1

php keeps freeezing

Posted: Wed Mar 07, 2012 8:00 am
by IGGt
I have a page I designed to monitor some Databases. For the most part it works really well. But every so often it just seems to freeze mid refresh (by which I mean it appears to be loading, but never gets there).

I use:

Code: Select all

<script language="javascript" type="text/javascript">setTimeout("location.reload();",$msrefresh);</script>
to refresh the page the every 60 seconds. To get round this I now have a timer that runs independently, and after 240 seconds I show a message on screen informing me it has stopped refreshing. I then click a button, which opens the page in a new tab, and uses

Code: Select all

setcookie("TSmonitor_v7t", "", time()-3600, "/");
to remove the Session Cookie (as this was the only thing I could find that worked). But this required that I manually close the original tab, otherwise the new tab simply freezes.

But now I am looking to use it overnight, so I need to
a) find out why it keeps freezing (always seems to be just before connecting to a database, but always a different one).
or
b) open the new tab and close the original tab automatically (apparently it isn't possible to close the tab, as it wasn't created by the javascript).

And i'm not having much luck with either at the minute.

If anybody has any suggestions it would be greatly appreciated.

Re: php keeps freeezing

Posted: Wed Mar 07, 2012 8:02 am
by kon
Is the JavaScript variable $msrefresh defined in JavaScript or in PHP?

Re: php keeps freeezing

Posted: Wed Mar 07, 2012 8:14 am
by IGGt
It's a PHP variable - the full code for it is:

Code: Select all

//Page Refresh
$msrefresh = $pageRefresh*1000;
	if ($pageRefresh == 0) {
		$RefreshTime = "<!--<script language=\"javascript\" type=\"text/javascript\">setTimeout(\"location.reload();\",$msrefresh);</script>-->\n";
	} else {
		$RefreshTime = "<script language=\"javascript\" type=\"text/javascript\">setTimeout(\"location.reload();\",$msrefresh);</script>\n";
	};

Re: php keeps freeezing

Posted: Wed Mar 07, 2012 8:19 am
by kon
Why to put comments if it is zero ? ... also testing your code what is the $msrefresh and where do you output it ?

Re: php keeps freeezing

Posted: Wed Mar 07, 2012 8:31 am
by IGGt
I put it in comments initially so that when I was designing the page I could see where it should go when looking at the HTML output, but the comments would prevent it from being acted on.

$pageRefresh is a configurable time in seconds, that generally is set to 60. (0 means it doesn't auto refresh for testing purposes).
$msRefresh is $pageRefresh*1000 which is then placed into the Javascript to set the time to refresh the page.

It is placed in the <head> tag. e.g.

Code: Select all

<head>
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
		<title>monitoring</title>
		<link rel="stylesheet" type="text/css" href="CS.css" />
		<?php print $RefreshTime; ?>
</head>