Hey guys,
This seems like something that is extremely easy, but I've been playing with it for a few days, and am still at a loss. I'm working on a fairly large PHP program, and basically, it gathers info from the DB, generates a nice HTML page, and displays it to the browser. It's straight PHP code, and the HTML is all dynamically generated. Nice and simple.
There's only one function that outputs to the browser, and this ends up getting executed three times during the one process. For some unknown reason though, on some (not all) pages, it only displays maybe 90% of the HTML code, then stalls / hangs. I'm using ob_start() and ob_end_flush(), and have tried without them as well.
I've checked everything over and over, and can't see a problem anywhere. I even had the script save all HTML that gets outputed to a file, and that webpage shows up just fine in my browser with 100% of the HTML code. When it's displayed through the PHP script though, it will sometimes hang.
Anybody have any idea why something like this would be happening? Any pointers?
Thanks,
Matt
echo / print Help
Moderator: General Moderators
Unfortunately, not really. There's about 20 different functions that make it work the way it does, and posting ~800 lines of code probably isn't a good idea. But, I can ensure that the HTML code is being generated properly, and passed to the one function properly. That one function is the only place that anything is outputted to the browser.
When saving the code passed to that function to a text file, everything works just fine. It just sometimes hangs / stalls when the PHP script tries to display it. *shrug*
Thanks,
Matt
When saving the code passed to that function to a text file, everything works just fine. It just sometimes hangs / stalls when the PHP script tries to display it. *shrug*
Thanks,
Matt
I see your point, but without anything to work with it's going to be difficult to pinpoint the error. If you've got that much code I can suggest the following:
Either...
1. Start commenting out chunks of code that may cause problems until you find the culprit. This will usually happen when your page renders correctly, or at least doesn't hang.
2. Create a test page with the bare-bones of youre 800-line code, ie: shorten it to a simple echo. Then, work yourself upwards by adding code until you find the code that breaks the page rendering.
I know that's very general, but that's all I can offer without a "hands-on" access to code.
Either...
1. Start commenting out chunks of code that may cause problems until you find the culprit. This will usually happen when your page renders correctly, or at least doesn't hang.
2. Create a test page with the bare-bones of youre 800-line code, ie: shorten it to a simple echo. Then, work yourself upwards by adding code until you find the code that breaks the page rendering.
I know that's very general, but that's all I can offer without a "hands-on" access to code.
-
phpCCore Brad
- Forum Commoner
- Posts: 47
- Joined: Sun Dec 04, 2005 5:46 pm
- Location: Michigan, USA
- Contact:
Hmm
Are you scripting with all errors on? It could be a simple error that is only happening with those rare outputs. Also are you using shutdown functions? I had a similar problem using an output buffer on shutdown. Basically, php randomly changes the directory before the shutdown functions and if you are getting files you won't be in the right directory.
Nah, I managed to figure it out (kind of). I uploaded everything to my LINUX server (use my Windows computer for development) and all worked fine. Then I realized it was because I had Apache configured to pipe all PHP scripts through that php-cgi.exe file. I changed that around so the php5 module was loaded instead, and now all works fine. *shrug*