php keeps freeezing

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
IGGt
Forum Contributor
Posts: 173
Joined: Thu Nov 26, 2009 9:22 am

php keeps freeezing

Post 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.
Last edited by IGGt on Wed Mar 07, 2012 8:12 am, edited 1 time in total.
kon
Forum Newbie
Posts: 19
Joined: Sat Mar 03, 2012 5:43 am

Re: php keeps freeezing

Post by kon »

Is the JavaScript variable $msrefresh defined in JavaScript or in PHP?
IGGt
Forum Contributor
Posts: 173
Joined: Thu Nov 26, 2009 9:22 am

Re: php keeps freeezing

Post 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";
	};
kon
Forum Newbie
Posts: 19
Joined: Sat Mar 03, 2012 5:43 am

Re: php keeps freeezing

Post by kon »

Why to put comments if it is zero ? ... also testing your code what is the $msrefresh and where do you output it ?
IGGt
Forum Contributor
Posts: 173
Joined: Thu Nov 26, 2009 9:22 am

Re: php keeps freeezing

Post 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>
Post Reply