Jump to content

Recommended Posts

Posted

there seems a lot of confusion on the net about whether this works or not; I'm trying to use it and it's not working. I'm not sure if I'm doing it wrong or it's not working. Any experiences?

 

trying to use

while (@ob_end_flush()); 

 

This is for a amazon api page. If I try to do more than 1 lookup per second,some lookups fail so it would be nice if the page wrote each row in the table as it got the information. At the moment the page is only 12 rows (1 lookup per row) but it could conceivably get upto as 300 rows.

Posted

Aren't you doing the opposite to what you want though? :s As in you're buffering stuff, and not sending it directly. (Depending on your code obviously)

 

echo 'MyShinies'; 

ob_start(); 
echo 'Buffer1'; 
echo 'Buffer2'; 
while (@ob_end_flush()); 

?> 

 

As in that example above MyShinies would be direct, and the 2 buffers would only get flushed when you run the ob_end_flush, so it'd get saved up if you had a loop (guessing your setup):

 

ob_start(); 
for ($x = 0; $x <= 10000; $x++) {
    DO SOME AMAZON STUFF....
    echo 'Buffer XYZ';
} 
while (@ob_end_flush()); 
?> 

 

So if that's your api search it wouldn't output anything until the end as that's when you flush it.

 

Or did I completely misunderstand what you meant? :o

 

Steve

  • Thanks 1
Posted

the code is like:

 

read database

for each item do {

amazon lookup

print table row (multiple lines)

}

which writes the whole table when its finished looping but I'd like it to flush each row.

Posted

If you're using ob, you should be able to do it like this:

 


for ($x = 0; $x <= 10000; $x++) {
    DO SOME AMAZON STUFF....
    echo $Stuff;
    flush();
    ob_flush();	
} 

?>

 

Steve

  • Thanks 1
Posted (edited)
That doesn't seem to work at all only it seems to stop the server erroring over how long it takes to load the page now. As if the code is working but the browser (firefox 33.1) isn't displaying it till the end. Edited by browolf
Posted

What server etc you running this on? As only other thing I've seen override it is the local buffers on the server (especially if Windows based), and obviously things like the built in cache on browsers (IE being 1024 before flushing etc)

 

Steve

Posted
it's an online host so no idea what the server is. An alternative I think is rewriting how the amazon api lookups work. Doing them as a batch in one lookup but I'm avoiding that as long as possible :D I can manage with how it is for now. Thanks.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...