[PHP] [OUTPUT BUFFER] - problems with redirects
So, I'm have this site where all this code was developed and the logic sits in different plugins throughout a template. So, html is output and then hits one of these plugins. Plugins do some processing and then hit a header(location...) redirect. So, problem is they developed code with these header redirects and now we there's too much html being output so we get the buffer errors Cannot modify header information - headers already sent by (output started at /home/carma/templates_c/carma^0^31^811^%%E2^E22^E22E607D%%carma%3Amenu.php:138) to fix we have to up the buffer ouput in the php to something really high. So, as far as I know this is not good coding practice and upping the output buffer is really masking the problem. Is there another way to work around this like another way to do redirects that won't cause these buffer probs? Thanks, T
Re: [PHP] [OUTPUT BUFFER] - problems with redirects
On Thu, Aug 19, 2010 at 6:01 PM, Tristan sunnrun...@gmail.com wrote: So, I'm have this site where all this code was developed and the logic sits in different plugins throughout a template. So, html is output and then hits one of these plugins. Plugins do some processing and then hit a header(location...) redirect. So, problem is they developed code with these header redirects and now we there's too much html being output so we get the buffer errors Cannot modify header information - headers already sent by (output started at /home/carma/templates_c/carma^0^31^811^%%E2^E22^E22E607D%%carma%3Amenu.php:138) to fix we have to up the buffer ouput in the php to something really high. So, as far as I know this is not good coding practice and upping the output buffer is really masking the problem. Is there another way to work around this like another way to do redirects that won't cause these buffer probs? Thanks, T I believe the error is informing you that some content has already been sent back to the client. Once any content has been sent back, the headers have already been set and you can't subsequently call header(). For an easy fix, you should be able to turn on output buffering for the request and all of the output will be held until the entire page is finished processing: http://php.net/manual/en/function.ob-start.php Alternatively, you can sift through you code looking for any output (even a single whitespace) that's present before the call to header in the menu.php file referenced in your error. Adam -- Nephtali: PHP web framework that functions beautifully http://nephtaliproject.com
[PHP] output buffer
I am receiving the Cannot send session cookie - headers already sent message even though I am using ob_start() at the top of my script. The php.ini file has output_buffering set to 4096 4096. My server is running Red Hat Enterprise Linux 5.2 I am using PHP 5.1.6 Is there some other setting I need to adjust to be able to start a session within the php script? Thanks Marc
Re: [PHP] output buffer
On Tue, Dec 29, 2009 at 4:09 PM, Marc Fromm marc.fr...@wwu.edu wrote: I am receiving the Cannot send session cookie - headers already sent message even though I am using ob_start() at the top of my script. The php.ini file has output_buffering set to 4096 4096. My server is running Red Hat Enterprise Linux 5.2 I am using PHP 5.1.6 Is there some other setting I need to adjust to be able to start a session within the php script? Thanks Marc Check that you don't have white space in your include files. One trick there is to remove the closing PHP tags '?' to avoid this problem -- Bastien Cat, the other other white meat -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] output buffer
I figured it out but not sure why. On the dev server the script ran with no errors On the live server the script created the header already sent error. In the code I did not execute ob_start() at the top of the script. Once I executed ob_start at the top of the script on the live server it worked with no header already sent error. I cannot see why on the dev server it works with the ob_start() command in inside the script while the live server had an error when it was in the same place in the script. -Original Message- From: Alexey Bovanenko [mailto:a.bovane...@gmail.com] Sent: Tuesday, December 29, 2009 1:38 PM To: Marc Fromm Subject: Re: [PHP] output buffer Hi. There're some other code that is sent to client. You must send cookie first, at header, then the other data. Please send code to view your case. With regards, Alexey On Wed, Dec 30, 2009 at 12:09 AM, Marc Fromm marc.fr...@wwu.edu wrote: I am receiving the Cannot send session cookie - headers already sent message even though I am using ob_start() at the top of my script. The php.ini file has output_buffering set to 4096 4096. My server is running Red Hat Enterprise Linux 5.2 I am using PHP 5.1.6 Is there some other setting I need to adjust to be able to start a session within the php script? Thanks Marc -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] output buffer
most probable error in your case is the dev server has output buffering enabled while it is turned off on the live server. try phpinfo to verify -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] output buffer with Chrome issue.
Hi Everyone, I'm trying to get Chrome to output html information as it comes thru. We have an iframe running a php script, and when the php script receives information, it outputs it. FF, IE, and Safari all work just fine, displays the info as it comes in. However, Chrome is not. It will only display the information after the php script stops executing. I am outputting this after every echo: echo str_pad( , 4096 ) . \n; flush(); ob_flush(); ob_implicit_flush(); Has anyone else had this issue? Anyone know how to fix it? -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month.
Re: [PHP] output buffer with Chrome issue.
On Fri, 2009-05-01 at 10:24 -0400, Dan Joseph wrote: Hi Everyone, I'm trying to get Chrome to output html information as it comes thru. We have an iframe running a php script, and when the php script receives information, it outputs it. FF, IE, and Safari all work just fine, displays the info as it comes in. However, Chrome is not. It will only display the information after the php script stops executing. I am outputting this after every echo: echo str_pad( , 4096 ) . \n; flush(); ob_flush(); ob_implicit_flush(); Has anyone else had this issue? Anyone know how to fix it? Have you tried a bigger pad? Try... oh I dunno... 40096. if that works then you can chop back until you find the threshold. Seems to be though that it might be better done as AJAX. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] output buffer with Chrome issue.
On Fri, May 1, 2009 at 10:29 AM, Robert Cummings rob...@interjinn.comwrote: Have you tried a bigger pad? Try... oh I dunno... 40096. if that works then you can chop back until you find the threshold. Seems to be though that it might be better done as AJAX. Hi, I tried that, didn't work at all even up to 144096 on the pad, but no dice. Ajax unfortunately isn't an option in this particular case. -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month.
Re: [PHP] output buffer with Chrome issue.
On Fri, 2009-05-01 at 10:34 -0400, Dan Joseph wrote: Ajax unfortunately isn't an option in this particular case. Why? Maybe you're thinking about it wrong. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] output buffer with Chrome issue.
On Fri, May 1, 2009 at 10:40 AM, Robert Cummings rob...@interjinn.comwrote: On Fri, 2009-05-01 at 10:34 -0400, Dan Joseph wrote: Ajax unfortunately isn't an option in this particular case. Why? Maybe you're thinking about it wrong. Maybe, I'm open to suggestions: Here's the basic way the application works. main index renders, javascript runs to create an iframe, and set the src='phpfile.php' that runs in a continuous loop. it connects to the server, and then listens for output. Disconnecting from the server isn't an option at all, or else the application will not function properly. It needs to have the constant stream to the server. Is there a better solution for this? -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month.
Re: [PHP] output buffer with Chrome issue.
On Fri, 2009-05-01 at 10:42 -0400, Dan Joseph wrote: On Fri, May 1, 2009 at 10:40 AM, Robert Cummings rob...@interjinn.comwrote: On Fri, 2009-05-01 at 10:34 -0400, Dan Joseph wrote: Ajax unfortunately isn't an option in this particular case. Why? Maybe you're thinking about it wrong. Maybe, I'm open to suggestions: Here's the basic way the application works. main index renders, javascript runs to create an iframe, and set the src='phpfile.php' that runs in a continuous loop. it connects to the server, and then listens for output. Disconnecting from the server isn't an option at all, or else the application will not function properly. It needs to have the constant stream to the server. Is there a better solution for this? I presume your backend script is running something that passes the data to the browser un-interrupted... maybe a shell script? You can wrap this in popen() or proc_open() and read the output as you would a file. This can then be queued for consumption by an AJAX script. Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] output buffer with Chrome issue.
On Fri, May 1, 2009 at 10:55 AM, Robert Cummings rob...@interjinn.comwrote: I presume your backend script is running something that passes the data to the browser un-interrupted... maybe a shell script? You can wrap this in popen() or proc_open() and read the output as you would a file. This can then be queued for consumption by an AJAX script. Ah ok, I've never used either of those before. I am going to give that a shot and will let you know how it goes. I should be able to bolt that on quickly. Thanks! -- -Dan Joseph www.canishosting.com - Plans start @ $1.99/month.
Re: [PHP] output-buffer and memory-issue
--- Robert Cummings [EMAIL PROTECTED] schrieb: On Wed, 2007-10-24 at 21:07 +, Werner Schneider wrote: Hi, I got a strange problem: Using php 4.4.x, I capture the whole output for a webpage into the output-buffer by using ob_start and ob_get_clean, because I got to make some replacements in the html-code before sending the page to the browser. This worked fine with a small page, but now I got a page for which the html-code is about 280 KB (not too big I think). But I get an server-error 500 for this script on my linux-based webhoster. I tried to run it on an local WAMP-installation - it worked without error. I temporarly deleted some of the output - it worked without error. I turned of the output-buffering - it worked without error. ... Any idea what I could do next? I got no access to the apache error-log, but the error is definitely connected to the output buffer and how much I try to store in it. Any help is welcome. Use some random URL parameter and detect it in your script. When detected enabled display errors: ?php if( isset( $_GET['knjdcrksjhfcsjkhfndkf'] ) ) { ini_set( 'display_errors', 1 ); } ? Then see if you get any errors. Although, if you're seg faulting, you still won't see an error since the program just dies. Thanks for your reply. It seems that this is happening, becaus even with your code I get no errors. It could be as well that the script dies before the printing of the output buffer starts, because it could be that the error is printed to the output buffer as well. Heute schon einen Blick in die Zukunft von E-Mails wagen? Versuchen Sie´s mit dem neuen Yahoo! Mail. www.yahoo.de/mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] output-buffer and memory-issue
Then see if you get any errors. Although, if you're seg faulting, you still won't see an error since the program just dies. Thanks for your reply. It seems that this is happening, becaus even with your code I get no errors. It could be as well that the script dies before the printing of the output buffer starts, because it could be that the error is printed to the output buffer as well. It seems that the error is not connected to the output-buffer, but to the preg_replace I do afterwards. I will start a new topic for that. Heute schon einen Blick in die Zukunft von E-Mails wagen? Versuchen Sie´s mit dem neuen Yahoo! Mail. www.yahoo.de/mail -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] output-buffer and memory-issue
Hi, I got a strange problem: Using php 4.4.x, I capture the whole output for a webpage into the output-buffer by using ob_start and ob_get_clean, because I got to make some replacements in the html-code before sending the page to the browser. This worked fine with a small page, but now I got a page for which the html-code is about 280 KB (not too big I think). But I get an server-error 500 for this script on my linux-based webhoster. I tried to run it on an local WAMP-installation - it worked without error. I temporarly deleted some of the output - it worked without error. I turned of the output-buffering - it worked without error. I printed memory_get_usage, but it never exceeded 2 MB (I load about 200 records from a database and create objects from it and then print the data of these 200 records). On phpinfo(), memory_limit of my webhoster is 40M - so 2MB SHOULD be no problem. I increased the memory-limit to 64M - it doesn't help. Any idea what I could do next? I got no access to the apache error-log, but the error is definitely connected to the output buffer and how much I try to store in it. Any help is welcome. Regards Wuschba __ Ihr erstes Fernweh? Wo gibt es den schönsten Strand? www.yahoo.de/clever -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] output-buffer and memory-issue
On Wed, 2007-10-24 at 21:07 +, Werner Schneider wrote: Hi, I got a strange problem: Using php 4.4.x, I capture the whole output for a webpage into the output-buffer by using ob_start and ob_get_clean, because I got to make some replacements in the html-code before sending the page to the browser. This worked fine with a small page, but now I got a page for which the html-code is about 280 KB (not too big I think). But I get an server-error 500 for this script on my linux-based webhoster. I tried to run it on an local WAMP-installation - it worked without error. I temporarly deleted some of the output - it worked without error. I turned of the output-buffering - it worked without error. I printed memory_get_usage, but it never exceeded 2 MB (I load about 200 records from a database and create objects from it and then print the data of these 200 records). On phpinfo(), memory_limit of my webhoster is 40M - so 2MB SHOULD be no problem. I increased the memory-limit to 64M - it doesn't help. Any idea what I could do next? I got no access to the apache error-log, but the error is definitely connected to the output buffer and how much I try to store in it. Any help is welcome. Use some random URL parameter and detect it in your script. When detected enabled display errors: ?php if( isset( $_GET['knjdcrksjhfcsjkhfndkf'] ) ) { ini_set( 'display_errors', 1 ); } ? Then see if you get any errors. Although, if you're seg faulting, you still won't see an error since the program just dies. Cheers, Rob. -- ... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] PHP output|Buffer, PLEASE ADVISE
Hi all; In general , when you open an html file , the browser start to display and draw the tables, then start to display the pictures (on slow internet connection).. but when you make your html code inside an php the output will be different, it will buffer everything then it will pop the whole page. I have a question.. how can I make php output and display my website as stream html.. because I have a postnuke website and it take ages for popping all contents , but when I saved it as html and I upload it on the same apache server , the home page start to be displayed picture after picture and so on ... Please any advise ?? Nabil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP output|Buffer, PLEASE ADVISE
On Sun, 21 Sep 2003, nabil wrote: In general , when you open an html file , the browser start to display and draw the tables, then start to display the pictures (on slow internet connection).. but when you make your html code inside an php the output will be different, it will buffer everything then it will pop the whole page. I have a question.. how can I make php output and display my website as stream html.. because I have a postnuke website and it take ages for popping all contents , but when I saved it as html and I upload it on the same apache server , the home page start to be displayed picture after picture and so on ... Please any advise ?? The output won't actually be different unless you have turned on zlib.output_compression or output_buffering in your php.ini file. Both of these are off by default. Without these PHP will not do any buffering. The only buffering you see is done by Apache and this buffering happens in your static file case as well. It is natural that a static file version of a big complex page will render faster than the PHP-generated one. You can ask Apache to flush its internal buffer by using the flush() call from PHP, but it really isn't advised to do that too often. Apache is buffering in order to spew out full TCP packets for maximum efficiency. Using flush() defeats that and your application end-to-end page delivery time will increase. -Rasmus -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP output|Buffer, PLEASE ADVISE
Check Activate compression setting in postnuke admin. You want it to be No. If this setting is activated, ob_start(ob_gzhandler); is called in pnInit() nabil wrote: Hi all; In general , when you open an html file , the browser start to display and draw the tables, then start to display the pictures (on slow internet connection).. but when you make your html code inside an php the output will be different, it will buffer everything then it will pop the whole page. I have a question.. how can I make php output and display my website as stream html.. because I have a postnuke website and it take ages for popping all contents , but when I saved it as html and I upload it on the same apache server , the home page start to be displayed picture after picture and so on ... Please any advise ?? Nabil -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php