nfr Posted January 21, 2007 Share Posted January 21, 2007 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. Quote Link to comment Share on other sites More sharing options...
redbullmarky Posted January 21, 2007 Share Posted January 21, 2007 have you tried it on another file to see if the problem is the same? Quote Link to comment Share on other sites More sharing options...
nfr Posted January 21, 2007 Author Share Posted January 21, 2007 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. Quote Link to comment Share on other sites More sharing options...
SharkBait Posted January 21, 2007 Share Posted January 21, 2007 The only time I have PHP 'hang' is because there is some crazy infinite loop running trying to output html.If the file becomes too big to output, i'm usually presented to download the file though. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 21, 2007 Share Posted January 21, 2007 Could you post the code if it's not too long? Perhaps there is a loop it's getting stuck in like SharkBait said. Quote Link to comment Share on other sites More sharing options...
nfr Posted January 28, 2007 Author Share Posted January 28, 2007 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:<?phpsession_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 = 900mysql_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_error());$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. Quote Link to comment Share on other sites More sharing options...
trq Posted January 28, 2007 Share Posted January 28, 2007 Honestly... the code is terrible. How many queries are you trying to run?[quote]If I remove the call to the included file, the page loads instantly[/quote]Can we see the included file then? Quote Link to comment Share on other sites More sharing options...
nfr Posted January 28, 2007 Author Share Posted January 28, 2007 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. Quote Link to comment Share on other sites More sharing options...
nfr Posted January 29, 2007 Author Share Posted January 29, 2007 Any ideas?Regards,Neil. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.