lapith Posted September 19, 2007 Share Posted September 19, 2007 Okay, so this is a difficult problem mostly because I cannot replicate it on a regular basis. I have created my first PHP based site and it is rather large with a lot of database calls, ajax, query string passing and session storage and javascript. The problem is that sometimes (again this seems to be happening at random) when I click on a link to go to another page on my site the website becomes unresponsive. That is to say that I can stop the page load and click on something else and the same thing happens (a loading animation with no progress). I can also try to refresh and get the same result. The only solution to this is to completely close the browser and open a new one and re-log into the site. Initially I was thinking that there was a problem with my database calls so I made sure to close them manually when I am done with them. I am still experiencing this problem. 1) Has anyone experienced something similar? How was it solved? 2) I am thinking it has something to do with sessions (just because I am trying to think of things that would possibly have influence on all my pages). My session handling is as follows: at the top of every page I check to make sure that a user is logged in: session_start(); if(!isset($_SESSION[ "web_user" ])){ header( "Location: /login.php" ); } from my understanding the above code should check to not only make sure that a session exists, but also that there is a valid web_user. Also many of my sub pages rely on there being certain session information, but I check those as well with something like: if(!isset($_SESSION[ "services_array" ])) { include("../scripts/php/create_services_array_action.php"); } (create_services_array_action.php creates the services_array session variable so that my page load can resume correctly.) 3) I have also checked my apache error log when this happens, but it doesn't seem to have any information about a specific problem. Any help or advice on where to look would be greatly appreciated. This problem is going to drive me mad. Quote Link to comment https://forums.phpfreaks.com/topic/69981-strange-and-seemingly-random-problem-with-my-site/ Share on other sites More sharing options...
btherl Posted September 20, 2007 Share Posted September 20, 2007 I've experienced plenty of problems like this. You can fix them with patience and hard work. First, determine a method of logging from each part of your code. Eg, the javascript can log what it is doing by editing the page and giving status updates. The php scripts can log to a file, or to output (if their output will be displayed to you). If the php script is responding to an ajax call, it will probably have to log to file. Then place debugging output throughout your program. This stage is simple. All you do is find which debugging output appears and which doesnt. Then you add more debugging statements at the point at which output stops. Eg. print "<b>Entering db call 3</b><br>"; ... print "<b>Passing data to foo()</b><br>"; If you see "entering db call 3" but you don't see "passing data to foo()", then you know where your script is hanging. So you add more debugging calls between those two statements. Eventually you find the exact statement where the script hangs. Then you have one line of code to debug, rather than thousands Quote Link to comment https://forums.phpfreaks.com/topic/69981-strange-and-seemingly-random-problem-with-my-site/#findComment-351518 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.