sphinx9999 Posted February 11, 2008 Share Posted February 11, 2008 I need to output data in two stages: I have an advert displaying script with a logger at the end. I am concerned that if my scripts cannot connect quickly to my logging db for any reason, the advert will not be displayed quickly. I need to force the advert to display, irrespective of whether it is logged. I know I should be able to this with output buffers (flush after echo $ad, then log) but this option is not available to me. Any other ways? Quote Link to comment Share on other sites More sharing options...
mikefrederick Posted February 11, 2008 Share Posted February 11, 2008 code? Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted February 11, 2008 Share Posted February 11, 2008 output buffering can do it for yuo simply put ob_start(); when you want to start buffering then ob_end_flush() and all buffered output will be outputted at this time along with an end of buffering Quote Link to comment Share on other sites More sharing options...
sphinx9999 Posted February 12, 2008 Author Share Posted February 12, 2008 Unfortunately I cannot use output buffering. I'm really asking if there are any alternatives to it. I know this sounds weird and I'm not sure if it would really work but I've been thinking of something along the lines of echoing out an html javascript tag with the src being another script with the logging functionality in it: echo $ad; echo '<script type="text/javascript" src="logging.php"></script> logging.php: <? //logging functionality here ?> This way all echo's would be performed AND THEN the logging would be done. However, if this works it will only work for an html output - great for my html page but not so good for my xml formatted version... Thanx Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted February 12, 2008 Share Posted February 12, 2008 why can't you OB? You could just put a div infront as a page warmer and when the page gets down to the last lines of execution change that div's style to display:none however its not as simple as OB would be. Quote Link to comment Share on other sites More sharing options...
sphinx9999 Posted February 12, 2008 Author Share Posted February 12, 2008 Yeah, I think buffering is going to be my only hope here - the div solution is good but won't work for my xml formatted page. I'm not sure why my development server is not allowing OBing. It stores the text in the buffer but does not output it seperately from the rest of the text. For example: ob_start(); echo 'test'; ob_end_flush(); sleep(3); echo 'another test'; I would expect 'test' to appear straightaway and then after a 3 second pause 'another test'. However, I just get a three second pause and then both strings appear together. Ho hum... Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted February 12, 2008 Share Posted February 12, 2008 thats in micro second Quote Link to comment Share on other sites More sharing options...
sphinx9999 Posted February 12, 2008 Author Share Posted February 12, 2008 thats in micro second nah, you're thinking of usleep! Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted February 12, 2008 Share Posted February 12, 2008 yeah your right try <?php echo "I'm going to Ob in 3 seconds"; sleep(3); ob_start(); echo "This is OB Output"; ob_end_flush(); sleep(3): echo "I'm out of OB for 3 seconds."; ?> Quote Link to comment Share on other sites More sharing options...
sphinx9999 Posted February 14, 2008 Author Share Posted February 14, 2008 No luck. Just got 6s pause and then the full output "I'm going to Ob in 3 secondsThis is OB OutputI'm out of OB for 3 seconds." ??? Quote Link to comment 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.