Re: [PHP] [OUTPUT BUFFER] - problems with redirects

2010-08-19 Thread Adam Richardson
On Thu, Aug 19, 2010 at 6:01 PM, Tristan  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


Re: [PHP] output buffer

2009-12-29 Thread kranthi
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



RE: [PHP] output buffer

2009-12-29 Thread Marc Fromm
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  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

2009-12-29 Thread Bastien Koert
On Tue, Dec 29, 2009 at 4:09 PM, Marc Fromm  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 with Chrome issue.

2009-05-01 Thread Dan Joseph
On Fri, May 1, 2009 at 10:55 AM, Robert Cummings wrote:

>
> 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 with Chrome issue.

2009-05-01 Thread Robert Cummings
On Fri, 2009-05-01 at 10:42 -0400, Dan Joseph wrote:
> On Fri, May 1, 2009 at 10:40 AM, Robert Cummings wrote:
> 
> > 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.

2009-05-01 Thread Dan Joseph
On Fri, May 1, 2009 at 10:40 AM, Robert Cummings wrote:

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

2009-05-01 Thread Robert Cummings
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.

2009-05-01 Thread Dan Joseph
On Fri, May 1, 2009 at 10:29 AM, Robert Cummings wrote:

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

2009-05-01 Thread Robert Cummings
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 and memory-issue

2007-10-25 Thread Werner Schneider

> > 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



Re: [PHP] output-buffer and memory-issue

2007-10-24 Thread Werner Schneider

--- 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:
> 
>  
> 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

2007-10-24 Thread Robert Cummings
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:



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