Page 1 of 1

echo / print Help

Posted: Sun Dec 04, 2005 5:33 am
by Envex
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

Posted: Sun Dec 04, 2005 6:11 am
by foobar
It's most likely something that you overlooked in your code. Could you post some of your code, per chance? It's a lot easier to tell what's wrong from looking at it than imagining what could be wrong. Help us to help you!

Posted: Sun Dec 04, 2005 6:16 am
by Envex
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

Posted: Sun Dec 04, 2005 6:29 am
by foobar
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.

Posted: Sun Dec 04, 2005 6:42 am
by Envex
Hmmm... After playing around a bit more, and I could be wrong, but it seems like the script is only "willing" to echo / print so much information, then hangs / stalls. Any reason why that would be? Or would this maybe be a server problem?

Matt

Hmm

Posted: Sun Dec 04, 2005 6:01 pm
by phpCCore Brad
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.

Posted: Mon Dec 05, 2005 5:49 am
by Envex
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*