Jump to content

PHP Hanging?


nfr

Recommended Posts


Hello -

I have an "index.php" file which used to parse fairly quickly. Now all of a sudden it seems to hang for about 30 seconds before completing to load. I have run "php index.php" on the command line and it seems to hang whilst just outputting HTML (actually within a simple table). Why would this happen? (There is no mysql db access at this point and I can't see anything unusual about the php or html.)

Any ideas?

Regards,

Neil.
Link to comment
Share on other sites


Hi -

Just tried now and yes it is. This never used to be a problem before and I have not made ANY changes to the php code. I did, however, have a server failure and am running on another machine. However, this machine is the same spec. Is there a php.ini parameter which may need to be set?

Regards,

Neil.
Link to comment
Share on other sites

Hi -

I narrowed it down to the following call:

<?php include("http://www.website.com/includes/counter/counter.php"); ?>

This file contains the following code:

<?php
session_start();
header("Cache-control: private");

require('../../Connections/leaderdb.php');

$remote_addr = $_SERVER['REMOTE_ADDR'];
$http_referer = $_SERVER['HTTP_REFERER'];
$http_user_agent = $_SERVER['HTTP_USER_AGENT'];
//echo "REMOTE_ADDR: $remote_addr";
//echo "HTTP_REFERER: $http_referer";
//echo "HTTP_USER_AGENT: $http_user_agent";

if(!session_is_registered('online')){
mysql_select_db($database_leaderdb, $leaderdb);
$sql_query1 = "INSERT INTO t_people_online (people_online_session_id, people_online_activity, people_online_ip_address, people_online_refurl,
people_online_user_agent) VALUES ('".session_id()."', now(), '{$_SERVER['REMOTE_ADDR']}', '{$_SERVER['HTTP_REFERER']}', '{$_SERVER['HTTP_USER_
AGENT']}')";
$result1 = mysql_query($sql_query1, $leaderdb);

session_register('online');
} else {
if(session_is_registered('user_id')){
mysql_select_db($database_leaderdb, $leaderdb);
$sql_query2 = "UPDATE t_people_online SET people_online_activity=now(), people_online_member='y' WHERE people_online_session_id='".session_id(
)."'";
$result2 = mysql_query($sql_query2, $leaderdb);
    }
}
if(session_is_registered('online')){       
mysql_select_db($database_leaderdb, $leaderdb);
$sql_query3 = "UPDATE t_people_online SET people_online_activity=now() WHERE people_online_session_id='".session_id()."'";
$result3 = mysql_query($sql_query3, $leaderdb);
}

$limit_time = time() - 900; // 15 Minute time out. 60 * 15 = 900
mysql_select_db($database_leaderdb, $leaderdb);
$sql_guests = mysql_query("SELECT * FROM t_people_online WHERE UNIX_TIMESTAMP(people_online_activity) >= $limit_time AND people_online_member=
'n' GROUP BY people_online_ip_address") or die (mysql_error());
$sql_guests = mysql_query("SELECT * FROM t_people_online WHERE UNIX_TIMESTAMP(people_online_activity) >= $limit_time AND people_online_member=
'n'") or die (mysql_error());
$sql_guests = mysql_query("SELECT * FROM t_people_online WHERE UNIX_TIMESTAMP(people_online_activity) >= $limit_time AND people_online_member=
'n'") or die (mysql_error());
mysql_select_db($database_leaderdb, $leaderdb);
$sql_members = mysql_query("SELECT * FROM t_people_online WHERE UNIX_TIMESTAMP(people_online_activity) >= $limit_time AND people_online_member
='y' GROUP BY people_online_ip_address") or die (mysql_error());
$sql_members = mysql_query("SELECT * FROM t_people_online WHERE UNIX_TIMESTAMP(people_online_activity) >= $limit_time AND people_online_member
='y'") or die (mysql_error());
mysql_select_db($database_leaderdb, $leaderdb);
$sql_hits = mysql_query("select * from t_site_statistics_details where site_statistics_id = 1 group by site_statistics_name") or die (mysql_er
ror());
$guests = mysql_num_rows($sql_guests);
$members = mysql_num_rows($sql_members);
if ($myrow = mysql_fetch_array($sql_hits)) {
do
{
$hits = $myrow["site_statistics_value"];
} while ($myrow = mysql_fetch_array($sql_hits));
}
echo "<p><span class=\"SiteStatisticsBoldRed\">Website Statistics</span><br />";
echo "<span class=\"SiteStatisticsRed\">Visitors Online: $guests</span><br />";
//echo "Members Online: $members<br />";
echo "<span class=\"SiteStatisticsRed\">Pages Served: $hits</span>";

mysql_select_db($database_leaderdb, $leaderdb);
$sql_query4 = "UPDATE t_site_statistics_details SET site_statistics_value=(site_statistics_value + 1) WHERE site_statistics_id=1";
$result4 = mysql_query("$sql_query4", $leaderdb);
?>

If I remove the call to the included file, the page loads instantly. There must be something wrong but I cna't see what. If I call the include file directly on the server it also loads instantly. So I don't know why it won't work inside the page...

Any ideas?

Regards,

Neil.
Link to comment
Share on other sites


Hi -

The code above is the included file ("counter.php"). At I said, it works fine as a direct call through the browser. It causes the page to hang, however, when called as an include in another php file...

Regards,

Neil.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.