Re: [PHP-DB] Headers sent error msg on one server but not the other...... .
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.....
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
Re: [PHP-DB] Headers sent error msg on one server but not the other ...... .
David Martínez wrote: 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. 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, -- - 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-DB] Headers sent error msg on one server but not the other...
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: if (mysql_num_rows($result) 0) { $_SESSION[valid_user] = $email; } elseif ($t_timestamp $c_timestamp) { HEADER(Location: logout.php); exit; } Best, CH __ Craig Hoffman ICQ / iChat: m0untaind0g __ -- 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.... .
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
Re: [PHP-DB] Headers sent error msg on one server but not the other.... .
Check that there is no output generated before your script hits the Header() function calls. The most common mistake I've noticed is that if you require() or include() many files before you call Header(), and if there is any content outside of the ?php ? tags in the includ()'ed or require()'d files (eg. a carraige return at the end, or a space after the ?. Check for that and that should fix your problem. 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: if (mysql_num_rows($result) 0) { $_SESSION[valid_user] = $email; } elseif ($t_timestamp $c_timestamp) { HEADER(Location: logout.php); exit; } Best, CH __ Craig Hoffman ICQ / iChat: m0untaind0g __ -- 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.... .
Thanks guys. There was a space after the closing ? tag. Best, Craig On Apr 28, 2005, at 2:08 PM, Patel, Aman wrote: Check that there is no output generated before your script hits the Header() function calls. The most common mistake I've noticed is that if you require() or include() many files before you call Header(), and if there is any content outside of the ?php ? tags in the includ()'ed or require()'d files (eg. a carraige return at the end, or a space after the ?. Check for that and that should fix your problem. 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: if (mysql_num_rows($result) 0) { $_SESSION[valid_user] = $email; } elseif ($t_timestamp $c_timestamp) { HEADER(Location: logout.php); exit; } Best, CH __ Craig Hoffman ICQ / iChat: m0untaind0g __ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php __ Craig Hoffman ICQ / iChat: m0untaind0g __ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] headers and if statements
?if($logIn != 1) {header(Location: loginError.php);}? Why does this direct me to loginError.php even when $logIn = 1? - Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] headers and if statements
Hum. Is $logIn null at times?!?! ?if($logIn != 1) {header(Location: loginError.php);}? Why does this direct me to loginError.php even when $logIn = 1? - Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] headers and if statements
Have you tried: ?php if (!$login=1) {header(Location: loginerror.php);)? -Original Message- From: Daniel Clark [mailto:[EMAIL PROTECTED] Sent: Friday, April 30, 2004 4:19 PM To: matthew perry Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] headers and if statements Hum. Is $logIn null at times?!?! ?if($logIn != 1) {header(Location: loginError.php);}? Why does this direct me to loginError.php even when $logIn = 1? - Matt -- 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
Re: [PHP-DB] headers and if statements
From: matthew perry [EMAIL PROTECTED] ?if($logIn != 1) {header(Location: loginError.php);}? Why does this direct me to loginError.php even when $logIn = 1? It doesn't. Double check your value of $logIn by printing it out or using print_r/vardump/etc... ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] headers and if statements
I think that would try to set $login=1. Need two == Have you tried: ?php if (!$login=1) {header(Location: loginerror.php);)? -Original Message- From: Daniel Clark [mailto:[EMAIL PROTECTED] Sent: Friday, April 30, 2004 4:19 PM To: matthew perry Cc: [EMAIL PROTECTED] Subject: Re: [PHP-DB] headers and if statements Hum. Is $logIn null at times?!?! ?if($logIn != 1) {header(Location: loginError.php);}? Why does this direct me to loginError.php even when $logIn = 1? - Matt -- 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 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] headers and if statements
From: Erik Meyer [EMAIL PROTECTED] Have you tried: ?php if (!$login=1) {header(Location: loginerror.php);)? Uhmm... Have _YOU_ tried that??? = vs == ? ;) ---John Holmes... -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP-DB] headers and if statements
I am testing now testing it with the ==, silly mistake -Original Message- From: John W. Holmes [mailto:[EMAIL PROTECTED] Sent: Friday, April 30, 2004 4:38 PM To: Erik Meyer; PHP-DB Subject: Re: [PHP-DB] headers and if statements From: Erik Meyer [EMAIL PROTECTED] Have you tried: ?php if (!$login=1) {header(Location: loginerror.php);)? Uhmm... Have _YOU_ tried that??? = vs == ? ;) ---John Holmes... -- 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
RE: [PHP-DB] headers and if statements
We've ALL done it before :-) I am testing now testing it with the ==, silly mistake -Original Message- From: John W. Holmes [mailto:[EMAIL PROTECTED] Sent: Friday, April 30, 2004 4:38 PM To: Erik Meyer; PHP-DB Subject: Re: [PHP-DB] headers and if statements From: Erik Meyer [EMAIL PROTECTED] Have you tried: ?php if (!$login=1) {header(Location: loginerror.php);)? Uhmm... Have _YOU_ tried that??? = vs == ? ;) ---John Holmes... -- 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 -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] headers already sent
When I insert the following header: header (Content-type: application/vnd.ms-excel); header (Content-Disposition: attachment ); I get the messages: *Warning*: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\trial.php:2) in *C:\Program Files\Apache Group\Apache2\htdocs\trial.php* on line *3* *Warning*: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\trial.php:2) in *C:\Program Files\Apache Group\Apache2\htdocs\trial.php* on line *4 *I get similar messages when I use my web host. How do I use these headers correctly? Matt
Re: [PHP-DB] headers already sent
You have some content at line 2 in file trial.php. Check if there is a space (or a session command) at that line. -- Jorge Oliveira » Cloreto.com matthew perry wrote: When I insert the following header: header (Content-type: application/vnd.ms-excel); header (Content-Disposition: attachment ); I get the messages: *Warning*: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\trial.php:2) in *C:\Program Files\Apache Group\Apache2\htdocs\trial.php* on line *3* *Warning*: Cannot modify header information - headers already sent by (output started at C:\Program Files\Apache Group\Apache2\htdocs\trial.php:2) in *C:\Program Files\Apache Group\Apache2\htdocs\trial.php* on line *4 *I get similar messages when I use my web host. How do I use these headers correctly? Matt -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP-DB] headers
How do I eanble headers in php3.ini file -Thanks -- The secret of the universe is @*í!'ñ^#+ NO CARRIER ___ _ _ _ |_|_||_||_||\/||_|| \ _|| || || \| || ||_/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP-DB] headers
When ever i add headers in my pages i get the following errors Can anybody tell me what's wrong? Warning: Cannot add header information - headers already sent by (output started at /usr/src/apache_1.3.14/web/server/apache/htdocs/searchdisplay.php:4) in /usr /src/apache_1.3.14/web/server/apache/htdocs/searchdisplay.php on line 6 -Sharmad -- The secret of the universe is @*!'^#+ NO CARRIER ___ _ _ _ |_|_||_||_||\/||_|| \ _|| || || \| || ||_/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP-DB] headers
Hi, you can't have ANY output whatsoever before adding a header. Even whitespaces before the opening ?php-tag are not possible. You also could turn "output_buffering" "ON" in your php.ini. But your ISP has to have them same setting and I don't know about disadvantages. So go with the first solution. Johannes "Sharmad Naik" [EMAIL PROTECTED] schrieb im Newsbeitrag [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... When ever i add headers in my pages i get the following errors Can anybody tell me what's wrong? Warning: Cannot add header information - headers already sent by (output started at /usr/src/apache_1.3.14/web/server/apache/htdocs/searchdisplay.php:4) in /usr /src/apache_1.3.14/web/server/apache/htdocs/searchdisplay.php on line 6 -Sharmad -- The secret of the universe is @*í!'ñ^#+ NO CARRIER ___ _ _ _ |_|_||_||_||\/||_|| \ _|| || || \| || ||_/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP-DB] headers
You need to put the headers before any output has been sent to the user, not line on line 6, line 2 if possible. This includes spaces or blank lines before the start of your php. e.g. Here is script that creates a simple image: ?php header ("Content-type: image/png"); $im = @ImageCreate (200, 200) or die ("Cannot Initialize new GD image stream"); $background_color = ImageColorAllocate ($im, 00, 00, 00); $text_color = ImageColorAllocate ($im, 233, 14, 91); ImageString ($im, 90, 20, 20, "Hello", $text_color); ImagePng ($im); ? Regards, Corin Rathbone [EMAIL PROTECTED] P.S. If you use the script you need the GD Image librays installed and enabled. -Original Message- From: Sharmad Naik [mailto:[EMAIL PROTECTED]] Sent: 07 April 2001 08:16 To: [EMAIL PROTECTED] Subject: [PHP-DB] headers When ever i add headers in my pages i get the following errors Can anybody tell me what's wrong? Warning: Cannot add header information - headers already sent by (output started at /usr/src/apache_1.3.14/web/server/apache/htdocs/searchdisplay.php:4) in /usr /src/apache_1.3.14/web/server/apache/htdocs/searchdisplay.php on line 6 -Sharmad -- The secret of the universe is @*!'^#+ NO CARRIER ___ _ _ _ |_|_||_||_||\/||_|| \ _|| || || \| || ||_/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]