Jump to content

[SOLVED] Possible Output buffer issue?


shayman

Recommended Posts

I'm not actually sure if this should go in the PHP, the MySQL or the Apache topic sections, but since it seems to be a PHP code issue, I'm putting it here in the hopes that someone can help me, or point me in the right direction.

 

Here's my situation: I've installed PHP (5), MySQL (5.1), and Apache2.2 onto my computer.  Everything is communicating correctly, and everything works more or less as well as it needs to.

 

My question is involving what I think might be an output buffer issue, but I'm not certain, so here's a hypothetical chunk of code that I'm going to use to illustrate what is happening:

 

$array = mysql_query("SELECT `name` FROM `table` ORDER BY `name`");

while($row = mysql_fetch_array($array)) //assume ~340 rows in the query result

{

    $name = mysql_escape_string($row['name']);

    [chunk of while loop code executed on $name that involves no echo statements];

    //it takes about 1.75 seconds to execute this code per iteration;

    echo "echo statement that should print at end of while loop code.<br>";

}

 

What SHOULD happen, and what happens when I run my script off of my GoDaddy-hosted database, is that the page starts loading HTML information immediately and each echo statement gets printed into the loading web page as it gets executed in the while loop (with, for arguments' sake, a noticeable time difference between each echo statement getting printed ).

 

What happens when I run the same script off my server is that no HTML data is sent to the browser until about 75 iterations into the while loop, at which point the page begins to load, and the first 75 or so while loop echo statements are printed simultaneously.  Then several minutes pass with no visible browser activity (presumably while the script is executing the next several while loops), and then the next ~75 echo statements are all printed simultaneously.  It continues to behave in this manner until the script is finished executing.

 

I can't figure out why the browser would not be executing each while loop echo statement as it gets executed by the script.

 

I thought it might have been an output buffer issue, so I went into my php.ini document and changed the setting of "output_buffer" from "4092" to "Off".  Then I stopped and restarted my server (so as to load the new php.ini file), checked to see that it was loading the correct settings, and ran the script again.

 

I got the same results.  So I looked into my httpd.conf file and couldn't really find anything that looked like it might have affected that.

 

Anyone have any ideas?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/137132-solved-possible-output-buffer-issue/
Share on other sites

Sounds like normal behaviour to me. Try setting implicit_flush to true to achieve the same affect as your godaddy server.

 

ps: I'm aware you just posted a simple example, but there is no need to escape data using mysql_real_escape_string when all your doing is displaying said data.

Sounds like normal behaviour to me. Try setting implicit_flush to true to achieve the same affect as your godaddy server.

 

ps: I'm aware you just posted a simple example, but there is no need to escape data using mysql_real_escape_string when all your doing is displaying said data.

 

It worked.  Thanks.

 

I guess we can consider this topic closed.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.