Re: [PHP-DB] Headers sent error msg on one server but not the other...... .

2005-05-01 Thread David Martínez
Martin Norland wrote:
Personally I disagree with this.  Yes it's easy, but you should never enable 
a feature to fix a bug or problem when it can be tracked down (although 
obviously in time critical situations, using it as a 'band aid' is - 
sometimes - necessary).  With a quick pointer he was able to find it, and 
not impact the performance of his web server (output buffering will take 
more memory - since it's obviously buffering all the output)

More importantly though, with output buffering - no content is sent to the 
client until you flush - in your suggestion at the end.  This isn't always 
an issue since many scripts do much of their processing at the top anyway, 
but if nothing is sent to the browser - the users will (the majority of the 
time) see the page they were on, and continue interacting with it thinking 
their request didn't go through.  This will only increase load on your 
server and, depending on what the users are doing (and how your backend is 
written) could throw someone or something into a state of confusion.

cheers,
--
Ok, then you must find those characters that are sent before you modify the 
header. Commonly are spaces or returns.
In the error HEADER ALREADY SENT .. also appears the line number that 
started the output. I hope this can be useful.

I hope you can find those characters.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Headers sent error msg on one server but not the other.....

2005-04-29 Thread David Martínez
I suggest you to activate Output Buffering at beggining of your code. It's 
so easy and should not modify the output of your code.
This prevents your error Headers already sent.
At the first line of your PHP code, insert ob_start() and in the end of 
your code insert ob_clean_flush().

If you do not want to use Output Buffering you should remove any character 
sent, including Cr Lf (\n\r). I think it's so hard and I don't recommend it.

Depending of your server, PHP can evaluate \n\r as nothing or evaluate \n\r 
as an output.

Craig Hoffman wrote:
Hey Folks,
I have a script that times out the session if there is no activity in a 
certain amount of time.  If there is no activity the HEADER()  redirects to 
the logout page and kills the session.  Everything works fine on our test 
server, but when I test the script on the production server, I get  an 
error HEADERS ALREADY SENT... after no activity.  I know all this stuff 
needs to be on top, before any  XHTML.

The test server has reg globals = OFF and the production server has them 
set to ON.  I can't change the any PHP.INI settings on the production 
server. Both servers are running PHP 4.3.10.  Other than that PHP 
installation is close to identical.   Any ideas / thoughts on what's 
causing the production server to send this error out?  Something to steer 
me in the right direction... I'm attaching a code snippet to look at:
Something is generating output before you get there - it could be as simple 
as:
---
?php
$stuff = '';
?

?php
$otherstuff = '';
?
---
Did you spot it?  That's right - a carriage return was sent.  Since your 
application works locally, I'd have to assume something is sending output 
before your scripts even start.  Is there any kind of header, wrapper, 
server-side include, or anything around the script - or perhaps you're 
making use of output buffering and the server isn't allowing its use?

cheers,
--
- Martin Norland, Sys Admin / Database / Web Developer, International 
Outreach x3257
The opinion(s) contained within this email do not necessarily represent 
those of St. Jude Children's Research Hospital.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php