Re: [PHP] Header problem - SOLVED

2009-10-19 Thread Kim Madsen
This has been solved today. Talawa had a similar problem and came up 
with a solution to his problem, namely using session_write_close() 
before creating the headers. That stunt also solved my problem :-)


--
Kind regards
Kim Emax

Kim Madsen wrote on 2009-10-03 13:30:

Hi PHP people

I have a really strange and annoying problem. I've got a site, where
members can download music. User clicks index.php (in index.php
there's an iframe, that opens another file), if certain check are okay
then a popup window opens download.php, where a mp3 file is fetched
from the server and renamed in the header, then pushed to the enduser,
this works fine. But now I want to create zipfiles too but when a user
downloads a zipfile it's like the whole site is freezed until download
has completed. My guess is that this is some sort of header problem
(see headers below), due to three headers at the same time, cause the
class works as expected in the test page i've created. Inputs to
correct headers would be appriciated very much :-)

Mp3 headers:
 $new_filename = attachment; filename=\{$artist} - {$title}.mp3\;
 header('Content-Description: File Transfer');
 header(Content-Type: application/octet-stream);
 header(Content-Length: $size);
 header(Content-Disposition: $new_filename);
 header(Content-Transfer-Encoding: binary);
 readfile($source_file);

Zip headers:
 $zip = new zipfile();
 $zip-add_dir(.);
 $new_filename= {$artist} - {$title}.mp3;
 if(mysql_num_rows($result)) {
   $zip-add_file($file, $new_filename);
 }
 header(Pragma: public);
 header(Expires: 0);
 header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
 header(Cache-Control: private,false);
 header(Content-type: application/zip);
 #header(Content-Type: application/octet-stream);
 header(Content-disposition: attachment; filename=\zipTest.zip\);
 header('Content-Transfer-Encoding: binary');
 ob_end_clean();
 echo $zip-file();

Code example: http://lps.netlinq.dk/test010/test_zip.class.php

Headers (fetched with firefox add-on: live http headers)

This is headers from the site, where the problem occurs:

1. click on the link to a title (Maxwell in this case)
--
http://lps.netlinq.dk/?action=downloadtrack_id=357

GET /?action=downloadtrack_id=357 HTTP/1.1
Host: lps.netlinq.dk
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/
20090803 Ubuntu/9.04 (jaunty) Shiretoko/3.5.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://lps.netlinq.dk/?action=downloadtrack_id=350
Cookie: login_email=kim%40emax.dk;
PHPSESSID=fbb5d6adec802766cf6f638c99ab4f1d

HTTP/1.x 200 OK
Date: Fri, 02 Oct 2009 15:15:21 GMT
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch
mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g
X-Powered-By: PHP/5.2.4-2ubuntu5.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-
check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 4250
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html

2. I click on download zip (this is a link to index.php)
if conditions are met, then a popup with download.php is activated and
here a zip header is made

--
http://lps.netlinq.dk/index.php

POST /index.php HTTP/1.1
Host: lps.netlinq.dk
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/
20090803 Ubuntu/9.04 (jaunty) Shiretoko/3.5.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://lps.netlinq.dk/?action=downloadtrack_id=357
Cookie: login_email=kim%40emax.dk;
PHPSESSID=fbb5d6adec802766cf6f638c99ab4f1d
Content-Type: application/x-www-form-urlencoded
Content-Length: 131
action=ask_questionsdownload_zipfile=1version_id
%5B1065%5D=1version_id%5B1066%5D=1version_id%5B1067%5D=1version_id
%5B1068%5D=1

HTTP/1.x 200 OK
Date: Fri, 02 Oct 2009 15:15:29 GMT
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch
mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g
X-Powered-By: PHP/5.2.4-2ubuntu5.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-
check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 3216
Keep-Alive: timeout=15, max=99
Connection: Keep-Alive
Content-Type: text/html
--
http://lps.netlinq.dk/download.php?track_id=357member_id=1string=41e0cd250ca3a40598e2019fd4c813cckbit=320zipfile=1 



GET /download.php?

Re: [PHP] Header problem - solved

2009-10-16 Thread Kim Madsen

Andrea Giammarchi wrote on 2009-10-05 18:26:


  There's a useful function called headers_sent() which checks to see if
  the headers have already been sent to the browser. This might be a good
  place to throw into your code at various points to check and see if
  something is being written which you don't expect.

true, check that as well, moreover, you talked about utf-8, well, if the 
BOM is automatically added, it can cause lots of problems ... still, 
only if you sent whatever to the output before the download.


I've tried a bunch of things, including link to index.php and as first 
thing check if the request is a zipfile, then throw a zip header, 
readfile the file then exit the code. Nothing helped. So I figured it 
could be a latin-1 / utf-8 problem and tried to post to a fresh new page 
(donwload_zip.php) instead, where I was sure the terminal and Vi was set 
to use latin-1, then it worked.


It's still not the ultimate solution as we wanted the zipfile to be 
created on the fly in memory in order not to have to delete files 
afterwards and to be sure that only allowed users can fetch the files 
(of course you can always put the zipfiles outside webscope, but still...)


--
Kind regards
Kim Emax

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



Re: [PHP] Header problem

2009-10-05 Thread Kim Madsen

Hi Andrea

Andrea Giammarchi wrote on 2009-10-04 19:36:
Unless I am missing something, your page has too many if and it always 
ends up with print something ... but there is no exit after the 
download, so the zip will have extra output included without a reason 
... which is an error, imho, dunno how else explain if you can't see 
your print links at the end of the page ...


Sorry, the .phps file wasn't updated, but the page still works as 
expected even though I've printed stuff after the header (i tested that 
just for fun).


I'm thinking I'll try and look at the included files, this is what 
happends before the headers are trown:


session_start();
$version_id = $_REQUEST['version_id'];
$track_id = $_REQUEST['track_id'];
$member_id = $_REQUEST['member_id'];
$string = $_REQUEST['string'];
$zipfile = $_REQUEST['zipfile'];

if($DOWNLOAD_OK) {
  include inc/connect.inc;
  include inc/functions.inc;
  include inc/default_functions.inc;

As you said earlier, spaces could do wierd stuff to a header

Also switching between utf-8 and latin-1 character sets can make php 
choke, I've experienced that before with sessions.


Kind regards
Kim


  Date: Sun, 4 Oct 2009 19:09:35 +0200
  From: php@emax.dk
  To: php-general@lists.php.net
  Subject: Re: [PHP] Header problem
 
  Hello Andrea
 
  Andrea Giammarchi wrote on 2009-10-04 18:49:
  
Header must come first (before you output anything) or you get a 
parse

error
  
   I try to better explain ...
  
   HTTP works like this: you ask something, you receive something, 
html and

   texts are just one option.
 
  Got it so far
 
   Your example page mess up html, zip, everything, because when you
   download a file you still have the rest of the page sent in the output.
 
  Nops, not really.
 
  index.php:
  print stuff
  do stuff
  open download.php in a _new_ window.
  print more stuff
  page end
 
  this should be possible, right? Two different headers for two different
  pages.
 
   A download should have ONLY file related info/headers and nothing else
   in the output ... echo/print in the middle of the code before an 
header

   is an error, everything in output before an header is an error,
   everything after headers that is not related to that header is an 
error,

   got my point?
 
  Jep! And that's actually what I do. What I could, is to add exit; after
  the headers have been sent and the file have been pushed. I do an update
  of the database to tell the system that the files in the zipfile has
  been downloaded.
 
   To decide how a page should behave, you must be able to do not produce
   anything except the expected output with expected headers, that's 
why I

   have said headers are fundamental for a response, we cannot play with
   outputs however we want.
 
  The only output is the headers of the zipfile:
 
  header('Accept-Ranges: bytes');
  header(Content-Type: application/zip);
  header(Content-Length: $size);
  header(Content-disposition: attachment;
  filename=\.basename($zip_filename).\);
  header(Content-Transfer-Encoding: binary);
  readfile($filename);
 
  // we need to reload top5 to have a current view
  unset($_SESSION['top5']);
  $_SESSION['reload_top5'] = 1;
 
  // NOTE second param shall be an array, not a variable when
  downloading zip files
  download_completed($member_id, $downloaded_version_ids);
 
  Wouldn't you say this is okay?
 
   As summary, once you have created and tried a dedicated page without a
   single white space or print before, during, or after the dedicated
   download stuff, I'll try to understand where is the error.
   Otherwise it could be everything, and I am against magic 
behaviors ...
   you need to download? Well, create a file which aims id to download 
and

   nothing else, or you gonna constantly find these kind of problems in
   your applications.
 
  I believe the testpage does forfill that request? Or do you mean 
otherwise?

 
  Kind regards
  Kim
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 


Windows Live Hotmail: Your friends can get your Facebook updates, right 
from Hotmail®. 
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009



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



Re: [PHP] Header problem

2009-10-05 Thread Ashley Sheridan
On Mon, 2009-10-05 at 18:10 +0200, Kim Madsen wrote:

 Hi Andrea
 
 Andrea Giammarchi wrote on 2009-10-04 19:36:
  Unless I am missing something, your page has too many if and it always 
  ends up with print something ... but there is no exit after the 
  download, so the zip will have extra output included without a reason 
  ... which is an error, imho, dunno how else explain if you can't see 
  your print links at the end of the page ...
 
 Sorry, the .phps file wasn't updated, but the page still works as 
 expected even though I've printed stuff after the header (i tested that 
 just for fun).
 
 I'm thinking I'll try and look at the included files, this is what 
 happends before the headers are trown:
 
 session_start();
 $version_id = $_REQUEST['version_id'];
 $track_id = $_REQUEST['track_id'];
 $member_id = $_REQUEST['member_id'];
 $string = $_REQUEST['string'];
 $zipfile = $_REQUEST['zipfile'];
 
 if($DOWNLOAD_OK) {
include inc/connect.inc;
include inc/functions.inc;
include inc/default_functions.inc;
 
 As you said earlier, spaces could do wierd stuff to a header
 
 Also switching between utf-8 and latin-1 character sets can make php 
 choke, I've experienced that before with sessions.
 
 Kind regards
 Kim
 
Date: Sun, 4 Oct 2009 19:09:35 +0200
From: php@emax.dk
To: php-general@lists.php.net
Subject: Re: [PHP] Header problem
   
Hello Andrea
   
Andrea Giammarchi wrote on 2009-10-04 18:49:

  Header must come first (before you output anything) or you get a 
  parse
  error

 I try to better explain ...

 HTTP works like this: you ask something, you receive something, 
  html and
 texts are just one option.
   
Got it so far
   
 Your example page mess up html, zip, everything, because when you
 download a file you still have the rest of the page sent in the output.
   
Nops, not really.
   
index.php:
print stuff
do stuff
open download.php in a _new_ window.
print more stuff
page end
   
this should be possible, right? Two different headers for two different
pages.
   
 A download should have ONLY file related info/headers and nothing else
 in the output ... echo/print in the middle of the code before an 
  header
 is an error, everything in output before an header is an error,
 everything after headers that is not related to that header is an 
  error,
 got my point?
   
Jep! And that's actually what I do. What I could, is to add exit; after
the headers have been sent and the file have been pushed. I do an update
of the database to tell the system that the files in the zipfile has
been downloaded.
   
 To decide how a page should behave, you must be able to do not produce
 anything except the expected output with expected headers, that's 
  why I
 have said headers are fundamental for a response, we cannot play with
 outputs however we want.
   
The only output is the headers of the zipfile:
   
header('Accept-Ranges: bytes');
header(Content-Type: application/zip);
header(Content-Length: $size);
header(Content-disposition: attachment;
filename=\.basename($zip_filename).\);
header(Content-Transfer-Encoding: binary);
readfile($filename);
   
// we need to reload top5 to have a current view
unset($_SESSION['top5']);
$_SESSION['reload_top5'] = 1;
   
// NOTE second param shall be an array, not a variable when
downloading zip files
download_completed($member_id, $downloaded_version_ids);
   
Wouldn't you say this is okay?
   
 As summary, once you have created and tried a dedicated page without a
 single white space or print before, during, or after the dedicated
 download stuff, I'll try to understand where is the error.
 Otherwise it could be everything, and I am against magic 
  behaviors ...
 you need to download? Well, create a file which aims id to download 
  and
 nothing else, or you gonna constantly find these kind of problems in
 your applications.
   
I believe the testpage does forfill that request? Or do you mean 
  otherwise?
   
Kind regards
Kim
   
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
   
  
  
  Windows Live Hotmail: Your friends can get your Facebook updates, right 
  from Hotmail®. 
  http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009
 
 

There's a useful function called headers_sent() which checks to see if
the headers have already been sent to the browser. This might be a good
place to throw into your code at various points to check and see if
something is being written which you don't expect.

Also, one method I use, is to write the content you would be 'printing

RE: [PHP] Header problem

2009-10-05 Thread Andrea Giammarchi


 There's a useful function called headers_sent() which checks to see if
 the headers have already been sent to the browser. This might be a good
 place to throw into your code at various points to check and see if
 something is being written which you don't expect.

true, check that as well, moreover, you talked about utf-8, well, if the BOM is 
automatically added, it can cause lots of problems ... still, only if you sent 
whatever to the output before the download.
  
_
Windows Live: Keep your friends up to date with what you do online.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_1:092010

Re: [PHP] Header problem

2009-10-04 Thread Kim Madsen

Andrea Giammarchi wrote on 2009-10-03 13:40:
 Do you want users download the file or the zip?

They can choose between the two.

 do you send other headers before the download?

Header must come first (before you output anything) or you get a parse 
error, so I'm not sure what you mean here? You can see the source of the 
class at the testpage I linked to.


 It's quite a common error to set a default header in PHP at the 
beginning of whatever application, while header should be used as last 
exit point and never in the middle, or at the beginning, of a response.


I'm not sure what you mean by this? My download.php first checks for the 
relevant data is there (track_id/version_id, a session with member_id), 
then if the download is allowed (by access or if it has already been 
downloaded) then it fetches the relevant files, zip these to the disk 
and first then... creates the zip header and afterwards uses a readfile 
on the zipfile just created.


 Moreover, if you use readfile and then zip what do you expect, 
multiple downloads in one? This is not how HTTP work ... so please show 
more php, or explain better what you would like to do.


What do you need to see besides the testpage?

If I have 4 mp3 files of 5mb each, these will be zipped into one 20mb 
file, and that is of course only one download. That's the wish from the 
siteowner: easier download of several mixes of the same artist/track


I hope this makes the problem more clear to you :-)

I've debugged some more into the problem, this is a header of a zip 
download where the site works as expected:


HTTP/1.x 200 OK
Date: Sat, 03 Oct 2009 22:26:45 GMT
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch 
mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g

X-Powered-By: PHP/5.2.4-2ubuntu5.6
Accept-Ranges: bytes
Content-Length: 7083675
Content-Disposition: attachment; filename=Maxwell - Bad Habits 
(Remixes) (index.php=get_zip).zip

Content-Transfer-Encoding: binary
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: application/zip

I call the file like this: index.php?get_zip=test_output.zip

index.php does this:

  $new_zipfile .= $_SESSION['download_title']..zip;
/*
  header(Cache-Control: no-cache);
  header(Pragma: no-cache);
  header(Expires: now);
*/
  header('Accept-Ranges: bytes');
  header(Content-Type: application/zip);
  header(Content-Length: .filesize($archiveName));
  header(Content-Disposition: attachment; filename=\$new_zipfile\);
  header(Content-Transfer-Encoding: binary);

  readfile($archiveName);
  exit;

The outcommented headers was put in because I discovered that the 
download then was cached after giving the file a strange name, that name 
never occured in the download :-/ I've ended up by making a workaround 
by adding nocache=.microtime(). to the get_zip link but then the site 
freezes againg during the download, arrrghh...


And headers from the original zip solution in download.php, headers are 
set in function.inc, this is the output from Live HTTP headers:


HTTP/1.x 200 OK
Date: Sat, 03 Oct 2009 21:41:49 GMT
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch 
mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g

X-Powered-By: PHP/5.2.4-2ubuntu5.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, 
pre-check=0

Pragma: no-cache
Accept-Ranges: bytes
Content-Length: 35756585
Content-Disposition: attachment; filename=Maxwell - Bad Habits 
(Remixes).zip

Content-Transfer-Encoding: binary
Keep-Alive: timeout=15, max=98
Connection: Keep-Alive
Content-Type: application/zip

difference to the returned zip headers in index.php is pragma, 
cache-control and expires, so I've removed these headers from the 
function, but they still show up:


HTTP/1.x 200 OK
Date: Sat, 03 Oct 2009 22:25:36 GMT
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch 
mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g

X-Powered-By: PHP/5.2.4-2ubuntu5.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, 
pre-check=0

Pragma: no-cache
Accept-Ranges: bytes
Content-Length: 7083675
Content-Disposition: attachment; filename=Maxwell - Bad Habits 
(Remixes).zip

Content-Transfer-Encoding: binary
Keep-Alive: timeout=15, max=96
Connection: Keep-Alive
Content-Type: application/zip

So I think my problem is cache related in some way.

Kind regards
Kim


  Date: Sat, 3 Oct 2009 13:30:38 +0200
  From: php@emax.dk
  To: php-general@lists.php.net
  Subject: [PHP] Header problem
 
  Hi PHP people
 
  I have a really strange and annoying problem. I've got a site, where
  members can download music. User clicks index.php (in index.php
  there's an iframe, that opens another file), if certain check are okay
  then a popup window opens download.php, where a mp3 file is fetched
  from the server and renamed in the header, then pushed

Re: [PHP] Header problem

2009-10-04 Thread Kim Madsen

Hi kranthi

kranthi wrote on 2009-10-03 16:21:
 Thats a lot of headers to read..
 At a first glance I can see that you did not specify a content-length
 header. this is a must and must be equal to the size of the file in
 bytes

I've noticed that too, but it's impossiple to determine the length of 
the zipfile, when creating the file in memory.


Instead I'm now writing the file to disk and uses filesize on the 
zipfile to get the length for Content-Length, then I use 
readfile(zipfile.zip) instead of echo $zip-file(); But the result is 
still the same :-/


Kind regards
Kim

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



Re: [PHP] Header problem

2009-10-04 Thread Ashley Sheridan
On Sun, 2009-10-04 at 18:10 +0200, Kim Madsen wrote:

 Hi kranthi
 
 kranthi wrote on 2009-10-03 16:21:
   Thats a lot of headers to read..
   At a first glance I can see that you did not specify a content-length
   header. this is a must and must be equal to the size of the file in
   bytes
 
 I've noticed that too, but it's impossiple to determine the length of 
 the zipfile, when creating the file in memory.
 
 Instead I'm now writing the file to disk and uses filesize on the 
 zipfile to get the length for Content-Length, then I use 
 readfile(zipfile.zip) instead of echo $zip-file(); But the result is 
 still the same :-/
 
 Kind regards
 Kim
 


Afaik, the content length header is not necessary, but it will cause
problems if it's set and it's wrong.

Thanks,
Ash
http://www.ashleysheridan.co.uk




RE: [PHP] Header problem

2009-10-04 Thread Andrea Giammarchi


 Header must come first (before you output anything) or you get a parse 
 error

I try to better explain ...

HTTP works like this: you ask something, you receive something, html and texts 
are just one option.

Your example page mess up html, zip, everything, because when you download a 
file you still have the rest of the page sent in the output.

A download should have ONLY file related info/headers and nothing else in the 
output ... echo/print in the middle of the code before an header is an error, 
everything in output before an header is an error, everything after headers 
that is not related to that header is an error, got my point?

To decide how a page should behave, you must be able to do not produce anything 
except the expected output with expected headers, that's why I have said 
headers are fundamental for a response, we cannot play with outputs however we 
want. 

As summary, once you have created and tried a dedicated page without a single 
white space or print before, during, or after the dedicated download stuff, 
I'll try to understand where is the error.
Otherwise it could be everything, and I am against magic behaviors ... you 
need to download? Well, create a file which aims id to download and nothing 
else, or you gonna constantly find these kind of problems in your applications.

Regards
  
_
Keep your friends updated—even when you’re not signed in.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_5:092010

RE: [PHP] Header problem

2009-10-04 Thread Andrea Giammarchi


 Afaik, the content length header is not necessary, but it will cause
 problems if it's set and it's wrong.

correct, missed Content-Length means the classic download with useless progress 
bar and undefined estimation time, problematic for preloader as well in case of 
images, swf, generic data, etc.

Content_length should be always present and it should be correct, but obviously 
if there are print or echo or other outputs non file related, Content-Length 
can simply mess up the response.
  
_
Windows Live: Friends get your Flickr, Yelp, and Digg updates when they e-mail 
you.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_3:092010

Re: [PHP] Header problem

2009-10-04 Thread Kim Madsen

Hello Andrea

Andrea Giammarchi wrote on 2009-10-04 18:49:


  Header must come first (before you output anything) or you get a parse
  error

I try to better explain ...

HTTP works like this: you ask something, you receive something, html and 
texts are just one option.


Got it so far

Your example page mess up html, zip, everything, because when you 
download a file you still have the rest of the page sent in the output.


Nops, not really.

index.php:
print stuff
do stuff
open download.php in a _new_ window.
print more stuff
page end

this should be possible, right? Two different headers for two different 
pages.


A download should have ONLY file related info/headers and nothing else 
in the output ... echo/print in the middle of the code before an header 
is an error, everything in output before an header is an error, 
everything after headers that is not related to that header is an error, 
got my point?


Jep! And that's actually what I do. What I could, is to add exit; after 
the headers have been sent and the file have been pushed. I do an update 
of the database to tell the system that the files in the zipfile has 
been downloaded.


To decide how a page should behave, you must be able to do not produce 
anything except the expected output with expected headers, that's why I 
have said headers are fundamental for a response, we cannot play with 
outputs however we want.


The only output is the headers of the zipfile:

  header('Accept-Ranges: bytes');
  header(Content-Type: application/zip);
  header(Content-Length: $size);
  header(Content-disposition: attachment; 
filename=\.basename($zip_filename).\);

  header(Content-Transfer-Encoding: binary);
readfile($filename);

  // we need to reload top5 to have a current view
  unset($_SESSION['top5']);
  $_SESSION['reload_top5'] = 1;

  // NOTE second param shall be an array, not a variable when 
downloading zip files

  download_completed($member_id, $downloaded_version_ids);

Wouldn't you say this is okay?

As summary, once you have created and tried a dedicated page without a 
single white space or print before, during, or after the dedicated 
download stuff, I'll try to understand where is the error.
Otherwise it could be everything, and I am against magic behaviors ... 
you need to download? Well, create a file which aims id to download and 
nothing else, or you gonna constantly find these kind of problems in 
your applications.


I believe the testpage does forfill that request? Or do you mean otherwise?

Kind regards
Kim

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



RE: [PHP] Header problem

2009-10-04 Thread Andrea Giammarchi

Unless I am missing something, your page has too many if and it always ends up 
with print something ... but there is no exit after the download, so the zip 
will have extra output included without a reason ... which is an error, imho, 
dunno how else explain if you can't see your print links at the end of the 
page ... 

Regards

 Date: Sun, 4 Oct 2009 19:09:35 +0200
 From: php@emax.dk
 To: php-general@lists.php.net
 Subject: Re: [PHP] Header problem
 
 Hello Andrea
 
 Andrea Giammarchi wrote on 2009-10-04 18:49:
  
Header must come first (before you output anything) or you get a parse
error
  
  I try to better explain ...
  
  HTTP works like this: you ask something, you receive something, html and 
  texts are just one option.
 
 Got it so far
 
  Your example page mess up html, zip, everything, because when you 
  download a file you still have the rest of the page sent in the output.
 
 Nops, not really.
 
 index.php:
 print stuff
 do stuff
 open download.php in a _new_ window.
 print more stuff
 page end
 
 this should be possible, right? Two different headers for two different 
 pages.
 
  A download should have ONLY file related info/headers and nothing else 
  in the output ... echo/print in the middle of the code before an header 
  is an error, everything in output before an header is an error, 
  everything after headers that is not related to that header is an error, 
  got my point?
 
 Jep! And that's actually what I do. What I could, is to add exit; after 
 the headers have been sent and the file have been pushed. I do an update 
 of the database to tell the system that the files in the zipfile has 
 been downloaded.
 
  To decide how a page should behave, you must be able to do not produce 
  anything except the expected output with expected headers, that's why I 
  have said headers are fundamental for a response, we cannot play with 
  outputs however we want.
 
 The only output is the headers of the zipfile:
 
header('Accept-Ranges: bytes');
header(Content-Type: application/zip);
header(Content-Length: $size);
header(Content-disposition: attachment; 
 filename=\.basename($zip_filename).\);
header(Content-Transfer-Encoding: binary);
 readfile($filename);
 
// we need to reload top5 to have a current view
unset($_SESSION['top5']);
$_SESSION['reload_top5'] = 1;
 
// NOTE second param shall be an array, not a variable when 
 downloading zip files
download_completed($member_id, $downloaded_version_ids);
 
 Wouldn't you say this is okay?
 
  As summary, once you have created and tried a dedicated page without a 
  single white space or print before, during, or after the dedicated 
  download stuff, I'll try to understand where is the error.
  Otherwise it could be everything, and I am against magic behaviors ... 
  you need to download? Well, create a file which aims id to download and 
  nothing else, or you gonna constantly find these kind of problems in 
  your applications.
 
 I believe the testpage does forfill that request? Or do you mean otherwise?
 
 Kind regards
 Kim
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
  
_
Windows Live Hotmail: Your friends can get your Facebook updates, right from 
Hotmail®.
http://www.microsoft.com/middleeast/windows/windowslive/see-it-in-action/social-network-basics.aspx?ocid=PID23461::T:WLMTAGL:ON:WL:en-xm:SI_SB_4:092009

Re: [PHP] Header problem

2009-10-04 Thread Tommy Pham
 Original Message 
 From: Kim Madsen php@emax.dk
 To: php-general@lists.php.net
 Sent: Sun, October 4, 2009 9:10:36 AM
 Subject: Re: [PHP] Header problem
 
 Hi kranthi
 
 kranthi wrote on 2009-10-03 16:21:
  Thats a lot of headers to read..
  At a first glance I can see that you did not specify a content-length
  header. this is a must and must be equal to the size of the file in
  bytes
 
 I've noticed that too, but it's impossiple to determine the length of the 
 zipfile, when creating the file in memory.
 
 Instead I'm now writing the file to disk and uses filesize on the zipfile to 
 get 
 the length for Content-Length, then I use readfile(zipfile.zip) instead of 
 echo $zip-file(); But the result is still the same :-/
 
 Kind regards
 Kim
 
 -- PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php

If you want to take advantage of chunked-transfer encoding, you can not specify 
'content-length'.


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



[PHP] Header problem

2009-10-03 Thread Kim Madsen

Hi PHP people

I have a really strange and annoying problem. I've got a site, where
members can download music. User clicks index.php (in index.php
there's an iframe, that opens another file), if certain check are okay
then a popup window opens download.php, where a mp3 file is fetched
from the server and renamed in the header, then pushed to the enduser,
this works fine. But now I want to create zipfiles too but when a user
downloads a zipfile it's like the whole site is freezed until download
has completed. My guess is that this is some sort of header problem
(see headers below), due to three headers at the same time, cause the
class works as expected in the test page i've created. Inputs to
correct headers would be appriciated very much :-)

Mp3 headers:
 $new_filename = attachment; filename=\{$artist} - {$title}.mp3\;
 header('Content-Description: File Transfer');
 header(Content-Type: application/octet-stream);
 header(Content-Length: $size);
 header(Content-Disposition: $new_filename);
 header(Content-Transfer-Encoding: binary);
 readfile($source_file);

Zip headers:
 $zip = new zipfile();
 $zip-add_dir(.);
 $new_filename= {$artist} - {$title}.mp3;
 if(mysql_num_rows($result)) {
   $zip-add_file($file, $new_filename);
 }
 header(Pragma: public);
 header(Expires: 0);
 header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
 header(Cache-Control: private,false);
 header(Content-type: application/zip);
 #header(Content-Type: application/octet-stream);
 header(Content-disposition: attachment; filename=\zipTest.zip\);
 header('Content-Transfer-Encoding: binary');
 ob_end_clean();
 echo $zip-file();

Code example: http://lps.netlinq.dk/test010/test_zip.class.php

Headers (fetched with firefox add-on: live http headers)

This is headers from the site, where the problem occurs:

1. click on the link to a title (Maxwell in this case)
--
http://lps.netlinq.dk/?action=downloadtrack_id=357

GET /?action=downloadtrack_id=357 HTTP/1.1
Host: lps.netlinq.dk
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/
20090803 Ubuntu/9.04 (jaunty) Shiretoko/3.5.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://lps.netlinq.dk/?action=downloadtrack_id=350
Cookie: login_email=kim%40emax.dk;
PHPSESSID=fbb5d6adec802766cf6f638c99ab4f1d

HTTP/1.x 200 OK
Date: Fri, 02 Oct 2009 15:15:21 GMT
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch
mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g
X-Powered-By: PHP/5.2.4-2ubuntu5.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-
check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 4250
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html

2. I click on download zip (this is a link to index.php)
if conditions are met, then a popup with download.php is activated and
here a zip header is made

--
http://lps.netlinq.dk/index.php

POST /index.php HTTP/1.1
Host: lps.netlinq.dk
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/
20090803 Ubuntu/9.04 (jaunty) Shiretoko/3.5.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://lps.netlinq.dk/?action=downloadtrack_id=357
Cookie: login_email=kim%40emax.dk;
PHPSESSID=fbb5d6adec802766cf6f638c99ab4f1d
Content-Type: application/x-www-form-urlencoded
Content-Length: 131
action=ask_questionsdownload_zipfile=1version_id
%5B1065%5D=1version_id%5B1066%5D=1version_id%5B1067%5D=1version_id
%5B1068%5D=1

HTTP/1.x 200 OK
Date: Fri, 02 Oct 2009 15:15:29 GMT
Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch
mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g
X-Powered-By: PHP/5.2.4-2ubuntu5.6
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-
check=0
Pragma: no-cache
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 3216
Keep-Alive: timeout=15, max=99
Connection: Keep-Alive
Content-Type: text/html
--
http://lps.netlinq.dk/download.php?track_id=357member_id=1string=41e0cd250ca3a40598e2019fd4c813cckbit=320zipfile=1

GET /download.php?
track_id=357member_id=1string=41e0cd250ca3a40598e2019fd4c813cckbit=320zipfile=1
HTTP/1.1
Host: lps.netlinq.dk
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/
20090803 Ubuntu/9.04 (jaunty) Shiretoko/3.5.2
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
*;q=0.8

RE: [PHP] Header problem

2009-10-03 Thread Andrea Giammarchi

Do you want users download the file or the zip?

do you send other headers before the download?

It's
quite a common error to set a default header in PHP at the beginning of
whatever application, while header should be used as last exit point
and never in the middle, or at the beginning, of a response.

Moreover,
if you use readfile and then zip what do you expect, multiple downloads
in one? This is not how HTTP work ... so please show more php, or
explain better what you would like to do.

Regards

 Date: Sat, 3 Oct 2009 13:30:38 +0200
 From: php@emax.dk
 To: php-general@lists.php.net
 Subject: [PHP] Header problem
 
 Hi PHP people
 
 I have a really strange and annoying problem. I've got a site, where
 members can download music. User clicks index.php (in index.php
 there's an iframe, that opens another file), if certain check are okay
 then a popup window opens download.php, where a mp3 file is fetched
 from the server and renamed in the header, then pushed to the enduser,
 this works fine. But now I want to create zipfiles too but when a user
 downloads a zipfile it's like the whole site is freezed until download
 has completed. My guess is that this is some sort of header problem
 (see headers below), due to three headers at the same time, cause the
 class works as expected in the test page i've created. Inputs to
 correct headers would be appriciated very much :-)
 
 Mp3 headers:
   $new_filename = attachment; filename=\{$artist} - {$title}.mp3\;
   header('Content-Description: File Transfer');
   header(Content-Type: application/octet-stream);
   header(Content-Length: $size);
   header(Content-Disposition: $new_filename);
   header(Content-Transfer-Encoding: binary);
   readfile($source_file);
 
 Zip headers:
   $zip = new zipfile();
   $zip-add_dir(.);
   $new_filename= {$artist} - {$title}.mp3;
   if(mysql_num_rows($result)) {
 $zip-add_file($file, $new_filename);
   }
   header(Pragma: public);
   header(Expires: 0);
   header(Cache-Control: must-revalidate, post-check=0, pre-check=0);
   header(Cache-Control: private,false);
   header(Content-type: application/zip);
   #header(Content-Type: application/octet-stream);
   header(Content-disposition: attachment; filename=\zipTest.zip\);
   header('Content-Transfer-Encoding: binary');
   ob_end_clean();
   echo $zip-file();
 
 Code example: http://lps.netlinq.dk/test010/test_zip.class.php
 
 Headers (fetched with firefox add-on: live http headers)
 
 This is headers from the site, where the problem occurs:
 
 1. click on the link to a title (Maxwell in this case)
 --
 http://lps.netlinq.dk/?action=downloadtrack_id=357
 
 GET /?action=downloadtrack_id=357 HTTP/1.1
 Host: lps.netlinq.dk
 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/
 20090803 Ubuntu/9.04 (jaunty) Shiretoko/3.5.2
 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
 *;q=0.8
 Accept-Language: en-us,en;q=0.5
 Accept-Encoding: gzip,deflate
 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
 Keep-Alive: 300
 Connection: keep-alive
 Referer: http://lps.netlinq.dk/?action=downloadtrack_id=350
 Cookie: login_email=kim%40emax.dk;
 PHPSESSID=fbb5d6adec802766cf6f638c99ab4f1d
 
 HTTP/1.x 200 OK
 Date: Fri, 02 Oct 2009 15:15:21 GMT
 Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch
 mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g
 X-Powered-By: PHP/5.2.4-2ubuntu5.6
 Expires: Thu, 19 Nov 1981 08:52:00 GMT
 Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-
 check=0
 Pragma: no-cache
 Vary: Accept-Encoding
 Content-Encoding: gzip
 Content-Length: 4250
 Keep-Alive: timeout=15, max=100
 Connection: Keep-Alive
 Content-Type: text/html
 
 2. I click on download zip (this is a link to index.php)
 if conditions are met, then a popup with download.php is activated and
 here a zip header is made
 
 --
 http://lps.netlinq.dk/index.php
 
 POST /index.php HTTP/1.1
 Host: lps.netlinq.dk
 User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.2) Gecko/
 20090803 Ubuntu/9.04 (jaunty) Shiretoko/3.5.2
 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/
 *;q=0.8
 Accept-Language: en-us,en;q=0.5
 Accept-Encoding: gzip,deflate
 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
 Keep-Alive: 300
 Connection: keep-alive
 Referer: http://lps.netlinq.dk/?action=downloadtrack_id=357
 Cookie: login_email=kim%40emax.dk;
 PHPSESSID=fbb5d6adec802766cf6f638c99ab4f1d
 Content-Type: application/x-www-form-urlencoded
 Content-Length: 131
 action=ask_questionsdownload_zipfile=1version_id
 %5B1065%5D=1version_id%5B1066%5D=1version_id%5B1067%5D=1version_id
 %5B1068%5D=1
 
 HTTP/1.x 200 OK
 Date: Fri, 02 Oct 2009 15:15:29 GMT
 Server: Apache/2.2.8 (Ubuntu) PHP/5.2.4-2ubuntu5.6 with Suhosin-Patch
 mod_ruby/1.2.6 Ruby/1.8.6(2007-09-24) mod_ssl/2.2.8 OpenSSL/0.9.8g
 X-Powered-By: PHP/5.2.4-2ubuntu5.6
 Expires

Re: [PHP] Header problem

2009-10-03 Thread kranthi
Thats a lot of headers to read..
At a first glance I can see that you did not specify a content-length
header. this is a must and must be equal to the size of the file in
bytes

-- 
Kranthi.

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



[PHP] header problem

2009-09-10 Thread A.a.k

hello
I recentrly uploaded my project from localhost to a hosting and found many 
errors and warnings which didnt have in local. one of the most annoying one 
is header('Location xxx').
I have used header to redirect users from pages, and kinda used it alot. i 
know about the whitespace causing warning, but most of the pages i'm sending 
users got html and php mixed so i'm confused about how to remove whitespace 
in a html/php file. the error is :

Warning: Cannot modify header information - headers already sent by 
here is a simple example, user update page :
if($valid)
   {
   $msg='111';
   $user-dbupdate();
header(Location: /admin/index.php?msg=$msg);

   }
   else
   {
foreach($errors as $val)
   echo 'p id=error'.$val.'/p';
   }

and on admin index i get $msg and display it.
html
..
//lots of stuff
  ?php
  $msg = $_GET['msg'];
  switch($msg){
  case '111'   echo 'p /p';
   break;
 case '421':...
   }
?
//  more html and php

how can i fix this? 



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



Re: [PHP] header problem

2009-09-10 Thread George Langley
	Hi Blueman. As soon as ANYTHING has been drawn to the browser, you  
cannot use a header command. So you need to work through all of your  
code, and ensure that all of your logic that could result in a header  
call is run BEFORE you send any html code. Is going to be tricky if  
mixing html and php calls.


George


On 10-Sep-09, at 12:27 AM, A.a.k wrote:


hello
I recentrly uploaded my project from localhost to a hosting and  
found many errors and warnings which didnt have in local. one of the  
most annoying one is header('Location xxx').
I have used header to redirect users from pages, and kinda used it  
alot. i know about the whitespace causing warning, but most of the  
pages i'm sending users got html and php mixed so i'm confused about  
how to remove whitespace in a html/php file. the error is :
Warning: Cannot modify header information - headers already sent  
by 

here is a simple example, user update page :
   if($valid)
  {
  $msg='111';
  $user-dbupdate();
   header(Location: /admin/index.php?msg=$msg);

  }
  else
  {
   foreach($errors as $val)
  echo 'p id=error'.$val.'/p';
  }

and on admin index i get $msg and display it.
html
..
//lots of stuff
 ?php
 $msg = $_GET['msg'];
 switch($msg){
 case '111'   echo 'p /p';
  break;
case '421':...
  }
?
//  more html and php

how can i fix this?

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




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



Re: [PHP] header problem

2009-09-10 Thread A.a.k

is there any alternative to header() for redirect users?

George Langley george.lang...@shaw.ca wrote in message 
news:b1b897d4-7448-4b71-bffc-3addc27ce...@shaw.ca...
Hi Blueman. As soon as ANYTHING has been drawn to the browser, you  cannot 
use a header command. So you need to work through all of your  code, and 
ensure that all of your logic that could result in a header  call is run 
BEFORE you send any html code. Is going to be tricky if  mixing html and 
php calls.


George


On 10-Sep-09, at 12:27 AM, A.a.k wrote:


hello
I recentrly uploaded my project from localhost to a hosting and  found 
many errors and warnings which didnt have in local. one of the  most 
annoying one is header('Location xxx').
I have used header to redirect users from pages, and kinda used it  alot. 
i know about the whitespace causing warning, but most of the  pages i'm 
sending users got html and php mixed so i'm confused about  how to remove 
whitespace in a html/php file. the error is :

Warning: Cannot modify header information - headers already sent  by 
here is a simple example, user update page :
   if($valid)
  {
  $msg='111';
  $user-dbupdate();
   header(Location: /admin/index.php?msg=$msg);

  }
  else
  {
   foreach($errors as $val)
  echo 'p id=error'.$val.'/p';
  }

and on admin index i get $msg and display it.
html
..
//lots of stuff
 ?php
 $msg = $_GET['msg'];
 switch($msg){
 case '111'   echo 'p /p';
  break;
case '421':...
  }
?
//  more html and php

how can i fix this?

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






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



Re: [PHP] header problem

2009-09-10 Thread Marcus Gnaß
A.a.k wrote:
 is there any alternative to header() for redirect users?

As far as I know there isn't.

Is the header-error the first error on the page? If not, the other error
message itself is the reason for the header-error and will be solved if
you solve the other error.

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



Re: [PHP] header problem

2009-09-10 Thread Ashley Sheridan
On Thu, 2009-09-10 at 08:57 +0200, A.a.k wrote:
 is there any alternative to header() for redirect users?
 
 George Langley george.lang...@shaw.ca wrote in message 
 news:b1b897d4-7448-4b71-bffc-3addc27ce...@shaw.ca...
  Hi Blueman. As soon as ANYTHING has been drawn to the browser, you  cannot 
  use a header command. So you need to work through all of your  code, and 
  ensure that all of your logic that could result in a header  call is run 
  BEFORE you send any html code. Is going to be tricky if  mixing html and 
  php calls.
 
  George
 
 
  On 10-Sep-09, at 12:27 AM, A.a.k wrote:
 
  hello
  I recentrly uploaded my project from localhost to a hosting and  found 
  many errors and warnings which didnt have in local. one of the  most 
  annoying one is header('Location xxx').
  I have used header to redirect users from pages, and kinda used it  alot. 
  i know about the whitespace causing warning, but most of the  pages i'm 
  sending users got html and php mixed so i'm confused about  how to remove 
  whitespace in a html/php file. the error is :
  Warning: Cannot modify header information - headers already sent  by 
  here is a simple example, user update page :
 if($valid)
{
$msg='111';
$user-dbupdate();
 header(Location: /admin/index.php?msg=$msg);
 
}
else
{
 foreach($errors as $val)
echo 'p id=error'.$val.'/p';
}
 
  and on admin index i get $msg and display it.
  html
  ..
  //lots of stuff
   ?php
   $msg = $_GET['msg'];
   switch($msg){
   case '111'   echo 'p /p';
break;
  case '421':...
}
  ?
  //  more html and php
 
  how can i fix this?
 
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
  
 
 

Several:

  * Javascript - not always available on your target system, or
blocked by script blocking plugins
  * Meta refresh tags - should be honored by the user agent, but may
not always be.

The problem you have is not that you need to work around this 'problem'
in PHP, but you need to fix your broken code. This problem often comes
up on the list, and is usually because of extra whitespace in include
files, or errors being output to the browser which force the headers to
be sent.

Thanks,
Ash
http://www.ashleysheridan.co.uk




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



Re: [PHP] header problem

2009-09-10 Thread HostWare Kft.
Usually, when I have to redirect the user AFTER headers has been sent (like 
showing an error message), I write this:


SCRIPTlocation=page_to_send.html/SCRIPT

But this will redirect the user at once. If you want the user to read the 
page, you should do something in Javascript with setTimeout(func,timeout) 
function.


BR,
SanTa

- Original Message - 
From: George Langley george.lang...@shaw.ca

To: php-general@lists.php.net
Sent: Thursday, September 10, 2009 8:39 AM
Subject: Re: [PHP] header problem


Hi Blueman. As soon as ANYTHING has been drawn to the browser, you  cannot 
use a header command. So you need to work through all of your  code, and 
ensure that all of your logic that could result in a header  call is run 
BEFORE you send any html code. Is going to be tricky if  mixing html and 
php calls.


George


On 10-Sep-09, at 12:27 AM, A.a.k wrote:


hello
I recentrly uploaded my project from localhost to a hosting and  found 
many errors and warnings which didnt have in local. one of the  most 
annoying one is header('Location xxx').
I have used header to redirect users from pages, and kinda used it  alot. 
i know about the whitespace causing warning, but most of the  pages i'm 
sending users got html and php mixed so i'm confused about  how to remove 
whitespace in a html/php file. the error is :

Warning: Cannot modify header information - headers already sent  by 
here is a simple example, user update page :
   if($valid)
  {
  $msg='111';
  $user-dbupdate();
   header(Location: /admin/index.php?msg=$msg);

  }
  else
  {
   foreach($errors as $val)
  echo 'p id=error'.$val.'/p';
  }

and on admin index i get $msg and display it.
html
..
//lots of stuff
 ?php
 $msg = $_GET['msg'];
 switch($msg){
 case '111'   echo 'p /p';
  break;
case '421':...
  }
?
//  more html and php

how can i fix this?

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




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




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



Re: [PHP] header problem

2009-09-10 Thread Ashley Sheridan
On Thu, 2009-09-10 at 09:04 +0200, Sándor Tamás (HostWare Kft.) wrote:
 Usually, when I have to redirect the user AFTER headers has been sent (like 
 showing an error message), I write this:
 
 SCRIPTlocation=page_to_send.html/SCRIPT
 
 But this will redirect the user at once. If you want the user to read the 
 page, you should do something in Javascript with setTimeout(func,timeout) 
 function.
 
 BR,
 SanTa
 
 - Original Message - 
 From: George Langley george.lang...@shaw.ca
 To: php-general@lists.php.net
 Sent: Thursday, September 10, 2009 8:39 AM
 Subject: Re: [PHP] header problem
 
 
  Hi Blueman. As soon as ANYTHING has been drawn to the browser, you  cannot 
  use a header command. So you need to work through all of your  code, and 
  ensure that all of your logic that could result in a header  call is run 
  BEFORE you send any html code. Is going to be tricky if  mixing html and 
  php calls.
 
  George
 
 
  On 10-Sep-09, at 12:27 AM, A.a.k wrote:
 
  hello
  I recentrly uploaded my project from localhost to a hosting and  found 
  many errors and warnings which didnt have in local. one of the  most 
  annoying one is header('Location xxx').
  I have used header to redirect users from pages, and kinda used it  alot. 
  i know about the whitespace causing warning, but most of the  pages i'm 
  sending users got html and php mixed so i'm confused about  how to remove 
  whitespace in a html/php file. the error is :
  Warning: Cannot modify header information - headers already sent  by 
  here is a simple example, user update page :
 if($valid)
{
$msg='111';
$user-dbupdate();
 header(Location: /admin/index.php?msg=$msg);
 
}
else
{
 foreach($errors as $val)
echo 'p id=error'.$val.'/p';
}
 
  and on admin index i get $msg and display it.
  html
  ..
  //lots of stuff
   ?php
   $msg = $_GET['msg'];
   switch($msg){
   case '111'   echo 'p /p';
break;
  case '421':...
}
  ?
  //  more html and php
 
  how can i fix this?
 
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 
 
  -- 
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
  
 
 
Don't use a timer to redirect if you want the user to read a message, as
this assumes that the visitor is a good reader. This is forgetting all
of those visitors with reading difficulties (i.e. Dyslexia), those users
who have attention problems who can't focus on text for long periods
(i.e. ADHD) and any users who rely on things such as screen readers
(which are slower than reading text yourself (if you're an average
reader!) ) or a Braille browser.

In cases such as these, it's best to let the visitor move at their own
pace and not redirect until they want to.

Thanks,
Ash
http://www.ashleysheridan.co.uk




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



RE: [PHP] header problem

2009-09-10 Thread Arno Kuhl
-Original Message-
From: A.a.k [mailto:blue...@gmail.com] 
Sent: 10 September 2009 08:27 AM
To: php-general@lists.php.net
Subject: [PHP] header problem

hello
I recentrly uploaded my project from localhost to a hosting and found many
errors and warnings which didnt have in local. one of the most annoying one
is header('Location xxx').
I have used header to redirect users from pages, and kinda used it alot. i
know about the whitespace causing warning, but most of the pages i'm sending
users got html and php mixed so i'm confused about how to remove whitespace
in a html/php file. the error is :
Warning: Cannot modify header information - headers already sent by 
here is a simple example, user update page :
 if($valid)
{
$msg='111';
$user-dbupdate();
 header(Location: /admin/index.php?msg=$msg);

}
else
{
 foreach($errors as $val)
echo 'p id=error'.$val.'/p';
}

and on admin index i get $msg and display it.
html
..
//lots of stuff
   ?php
   $msg = $_GET['msg'];
   switch($msg){
   case '111'   echo 'p /p';
break;
  case '421':...
}
?
//  more html and php

how can i fix this? 
--

It's possible that on your localhost you have output_buffering set on either
in php.ini or in a .htaccess, which would avoid the displayed error about
headers. If it's switched on locally and off for your host server then
you'll get the problem you reported. Check that this is off locally (use
phpinfo) so that you can be sure your code is working properly before you
upload.

Alternatively if you want to be able to do a redirect after you've already
started your output (this is sometimes done for error handling) you could
use ob_start() to start output buffering, ob_end_clean() to clear the output
buffer and start again, and ob_flush() to send the output buffer. If you
want to continue using output buffering after an ob_end_clean() you'll have
to do an ob_start() again.

Cheers
Arno


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



[PHP] header problem for mobile browser

2004-10-19 Thread QT
Hi,

I want to make a php file for download a jad file. I am using following
script to let browser understand that jad file is coming and download it.

But I have very interesting problem. If user open browser and write correct
addres following script let the download file.

But if the user open browser and write wrong addres and get some error.
After write correct address, still getting same error.

I think following script can not reset the previos header and browser still
using previous header and bring back an error.

What should I do, for this problem, any idea

$SRC_FILE = $file;
 $download_size = filesize($SRC_FILE);
 $filename = basename($SRC_FILE);
 header(Content-Type: text/vnd.sun.j2me.app-descriptor);
 header(Content-Disposition: attachment; filename=$filename);
 header(Accept-Ranges: bytes);
 header(Content-Length: $download_size);
 @readfile($SRC_FILE);

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



Re: [PHP] header problem for mobile browser

2004-10-19 Thread raditha dissanayake
QT wrote:
Hi,
I want to make a php file for download a jad file. I am using following
script to let browser understand that jad file is coming and download it.
 

Not sure If I have understood your question correctly but surely it 
would be easier for you to just add the following lines to your 
.htaccess file  and give a direct download link instead of trying to 
deliver through a php script.

addtype application/java-archive jar
addtype text/vnd.sun.j2me.app-descriptor jad
if you do deliver through a php script, the phone will follow up with a 
request for the jar file when it has recieved the jad file, your script 
needs to be able to handle that as well.

But I have very interesting problem. If user open browser and write correct
addres following script let the download file.
But if the user open browser and write wrong addres and get some error.
After write correct address, still getting same error.
I think following script can not reset the previos header and browser still
using previous header and bring back an error.
 

you cannot reset headers once they have been sent.  The headers you use 
seem ok but i would add a no-cache header as well.

header('Pragma: no-cache');
What should I do, for this problem, any idea
$SRC_FILE = $file;
$download_size = filesize($SRC_FILE);
$filename = basename($SRC_FILE);
header(Content-Type: text/vnd.sun.j2me.app-descriptor);
header(Content-Disposition: attachment; filename=$filename);
header(Accept-Ranges: bytes);
header(Content-Length: $download_size);
@readfile($SRC_FILE);
 


--
Raditha Dissanayake.

http://www.radinks.com/sftp/ | http://www.raditha.com/megaupload
Lean and mean Secure FTP applet with | Mega Upload - PHP file uploader
Graphical User Inteface. Just 128 KB | with progress bar.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP] header() problem!!!!

2002-09-11 Thread Jim lucas

This is not a bug.  This is just one of many differances between the big
browser war.  With Netscape (not sure which versions), the attachment thing
I found is required.  But with IE it kills the browser.

?

define('MSIE', (preg_match(/msie/i, $_SERVER['HTTP_USER_AGENT])?1:0));
header(Cache-Control: no-cache, must-revalidate);
header(Content-Type:.$mime_type);
header(Content-Disposition: .(MSIE?'':'attachment;
').filename=$filename);
echo $filedata;

?
- Original Message -
From: xdrag [EMAIL PROTECTED]
To: PHP Mailing List [EMAIL PROTECTED]
Sent: Saturday, September 07, 2002 7:38 PM
Subject: [PHP] header() problem


 Hi:
 is this a bug?
 [win98se + apache2.0.40 + PHP4.2.3 + IE6.0]

 download1.php:
 ?php
 ...
 header(Cache-Control: no-cache, must-revalidate);
 header(Content-Type:.$mime_type);
 header(Content-Disposition: filename=$filename);
 echo $filedata;
 ?
 works well

 download2.php:
 ?php
 ...
 header(Cache-Control: no-cache, must-revalidate);
 header(Content-Type:.$mime_type);
 header(Content-Disposition: attachment; filename=$filename);
 echo $filedata;
 ?
 please pay attention to header(Content-Disposition: ...)
 if you click this URL, for example download2.php?id=1, then click the
save button,
 your browser will suffer a fatal error. You can not do anything else now!




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




Re: [PHP] header() problem!!!!

2002-09-11 Thread Henrik Hudson

I have not had any problems on IE 6 with this. The code I am using on numerous 
scripts looks like this:

header(Content-Disposition: attachment; filename=$filename);
header(Content-Type: application/octet-stream);
fpassthru($filehandle);
fclose($filehandle);

Maybe the the combination of using the echo and the attachment field? The echo 
might not treat it as a real file? Just a thought.


On Wednesday 11 September 2002 03:33, Jim lucas wrote:
 This is not a bug.  This is just one of many differances between the big
 browser war.  With Netscape (not sure which versions), the attachment thing
 I found is required.  But with IE it kills the browser.

 ?

 define('MSIE', (preg_match(/msie/i, $_SERVER['HTTP_USER_AGENT])?1:0));
 header(Cache-Control: no-cache, must-revalidate);
 header(Content-Type:.$mime_type);
 header(Content-Disposition: .(MSIE?'':'attachment;
 ').filename=$filename);
 echo $filedata;

 ?
 - Original Message -
 From: xdrag [EMAIL PROTECTED]
 To: PHP Mailing List [EMAIL PROTECTED]
 Sent: Saturday, September 07, 2002 7:38 PM
 Subject: [PHP] header() problem

  Hi:
  is this a bug?
  [win98se + apache2.0.40 + PHP4.2.3 + IE6.0]
 
  download1.php:
  ?php
  ...
  header(Cache-Control: no-cache, must-revalidate);
  header(Content-Type:.$mime_type);
  header(Content-Disposition: filename=$filename);
  echo $filedata;
  ?
  works well
 
  download2.php:
  ?php
  ...
  header(Cache-Control: no-cache, must-revalidate);
  header(Content-Type:.$mime_type);
  header(Content-Disposition: attachment; filename=$filename);
  echo $filedata;
  ?
  please pay attention to header(Content-Disposition: ...)
  if you click this URL, for example download2.php?id=1, then click the

 save button,

  your browser will suffer a fatal error. You can not do anything else now!

-- 

Henrik Hudson
[EMAIL PROTECTED]

Note:  Beware of Dragons - Thou art crunchy and taste good with ketchup.


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




[PHP] header() problem!!!!

2002-09-07 Thread xdrag

Hi:
is this a bug?
[win98se + apache2.0.40 + PHP4.2.3 + IE6.0]

download1.php:
?php
...
header(Cache-Control: no-cache, must-revalidate);
header(Content-Type:.$mime_type);
header(Content-Disposition: filename=$filename);
echo $filedata;
?
works well

download2.php:
?php
...
header(Cache-Control: no-cache, must-revalidate);
header(Content-Type:.$mime_type);
header(Content-Disposition: attachment; filename=$filename);
echo $filedata;
?
please pay attention to header(Content-Disposition: ...)
if you click this URL, for example download2.php?id=1, then click the save button, 

your browser will suffer a fatal error. You can not do anything else now!



[PHP] header problem

2002-08-31 Thread mike

i'm setting up a messages option on my site, i was looking in the
documentation and read that if headers are not included in an e-mail, the
message is sent to the junk folder, i don't use hotmail (so i would not
know), however i am adding headers: using

// The headers
$myHeaders = From: \.Autoresponse.\ .$myAddress.\r\n;
$myHeaders .= To: \.$myName.\ .$myAddress.\r\n;
$myHeaders .= Reply-To: \.$myName.\ .$myAddress.\r\n;
$myHeaders .= MIME-Version: 1.0\r\n;
$myHeaders .= Content-Type: text/html; charset=iso-8859-1\r\n;
$myHeaders .= X-Priority: 1\r\n;
$myHeaders .= X-MSMail-Priority: High\r\n;
$myHeaders .= X-Mailer: Just My Server;

// send the e-mail
mail($myAddress, $mySubject, $myMessage, $myHeaders);

##
when testing the file i get the response e-mail, however at the top of the
e-mail i get the following:


Content-Type: text/html; charset=iso-8859-1 X-Priority: 1 X-MSMail-Priority:
High X-Mailer: Just My Server

this must mean that i have written the headers wrong, can someone point me
in the right direction

thanks

| Mike |



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




[PHP] header problem

2002-05-10 Thread SCOTT . NOVINGER

why does the name variable ($name) not display in the email body, but displays
just perfectly in the form result?

i can see everything from Employee ID: down in the email body, and
everything is seen in the form result.

have i made some error?

$bid_information = Name: .$name.\n
 .Employee ID: .$employee_id.\n
 .Month: .$month.\n
 .Aircraft: .$aircraft.\n
 .Position: .$position.\n
 .Bid Position: .$bid_position.\n
 .Revision: .$revision.\n\n
 .Choice 1: .$line1.\n
 .Choice 2: .$line2.\n
 .Choice 3: .$line3.\n
 .Choice 4: .$line4.\n;

  $fromaddress = [EMAIL PROTECTED];

  mail($toaddress, $subject, $fromaddress, $bid_information);


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




Re: [PHP] header problem

2002-05-10 Thread Analysis Solutions

On Fri, May 10, 2002 at 06:35:00PM -0700, [EMAIL PROTECTED] wrote:

   mail($toaddress, $subject, $fromaddress, $bid_information);

You have inverted the order of the body and additional_headers arguments.  Do this:

   mail($toaddress, $subject, $bid_information, $fromaddress);

Enjoy,

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

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




Re: [PHP] header problem

2002-05-10 Thread 1LT John W. Holmes

Read the manual page on mail(), also. Even if you switch the two like Dan
said, your headers are not in the appropriate format.

www.php.net/mail

---John Holmes...

- Original Message -
From: Analysis  Solutions [EMAIL PROTECTED]
To: PHP List [EMAIL PROTECTED]
Sent: Friday, May 10, 2002 11:16 AM
Subject: Re: [PHP] header problem


 On Fri, May 10, 2002 at 06:35:00PM -0700, [EMAIL PROTECTED]
wrote:

mail($toaddress, $subject, $fromaddress, $bid_information);

 You have inverted the order of the body and additional_headers arguments.
Do this:

mail($toaddress, $subject, $bid_information, $fromaddress);

 Enjoy,

 --Dan

 --
PHP classes that make web design easier
 SQL Solution  |   Layout Solution   |  Form Solution
 sqlsolution.info  | layoutsolution.info |  formsolution.info
  T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
  4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

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



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




Re: [PHP] header problem

2002-05-10 Thread Analysis Solutions

John:

On Fri, May 10, 2002 at 11:45:33AM -0400, 1LT John W. Holmes wrote:
 Read the manual page on mail(), also. Even if you switch the two like Dan
 said, your headers are not in the appropriate format.

Oh, you are sooo right!  I mistakenly thought he was setting the 
$toaddress when he was actually setting the $fromaddress variable.  Good catch.

Sorry,

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

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




[PHP] header problem - thank you!

2002-05-10 Thread SCOTT . NOVINGER

for all of you that replied to my original post, thank you.

all of the suggestions worked and i learned a couple of new things along the
way.

scott


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




[PHP] header() problem??

2002-03-11 Thread James E. Hicks III

I am trying to replace a perl script with the following PHP code. The perl code
acted like a redirector, sending you to a different script depending on the
value of the submit button. The following replacement code written in PHP works
quite well until the postString exceeds some unknown size (This number must be
known by someone because it is always chopping it at the same place). Why will
this not work and how can I fix it?? It seems to break when sending script has
more than 30 lines of form input, works fine otherwise.


?
while(list($key, $val) = each($HTTP_POST_VARS)) {
$key = stripslashes($key);
$val = stripslashes($val);
$key = urlencode($key);
$val = urlencode($val);
$postString .= $key=$val;
}
if ($defloc){
$gotoscript = $defloc;
}
$location = '/scriptdirectory/';
$go = http://www.site.com.$location.$gotoscript.?.$postString;
header(Location: $go);
?


James E Hicks III



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




Re: [PHP] header problem

2002-02-26 Thread Jim Lucas [php]

question, is this on a process page or on  a page that renders text?

Jim Lucas
- Original Message -
From: Michael P. Carel [EMAIL PROTECTED]
To: george Pitcher [EMAIL PROTECTED]
Cc: php [EMAIL PROTECTED]
Sent: Monday, February 25, 2002 5:44 PM
Subject: Re: [PHP] header problem


 Thank you George you are right, Im looking for a redirector once details
 have been checked in the form and written in the database, but how can i
do
 it what whould be the second option? i 've searching for javascript
 redirector but i cant find one. Could you please help me im stuck here.



 Regards,
 Mike


 - Original Message -
 From: george Pitcher [EMAIL PROTECTED]
 To: Michael P. Carel [EMAIL PROTECTED]
 Sent: Friday, February 22, 2002 5:44 PM
 Subject: Re: [PHP] header problem


  Michael,
 
  You cannot have any 'displayed' text prior to using the header function.
  You'll need to do this another way.
 
  Are you looking for automatic submission after completing a form or
  redirection once details have been checked.
 
  The first one is only possible with client-side scripting such as
  javascript (and I'm not sure if it's possible there). The second option
  is easy.
 
  HTH
 
  George
 
 
 
  On Fri, 2002-02-22 at 09:28, Michael P. Carel wrote:
   Hi ,
  
   I  have a problem in using the Header() function. I want to
 automatically
   redirect the page into another php script after a form completion but
im
   receiving this error Warning: Cannot add header information - headers
   already sent by ..
  
   Heres the script line:
  
   header(Location: 8D_Anaform_Admin.php?action=form);
  
   Please help im stuck here.
  
  
  
  
   Regards,
   Mike
  
  
 
 
 
  _
  Do You Yahoo!?
  Get your free @yahoo.com address at http://mail.yahoo.com


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




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




Re: [PHP] header problem

2002-02-26 Thread Michael P. Carel

thanks to all who help me regarding this problem, i've finally know the
cause of the header error message, i've got an HTML output on top of the
script (? center ?) I've overlooked that.
thanks for all of your clues and guide. hope to be as good as you there
guys.



Regards,
mike



- Original Message -
From: Jim Lucas [php] [EMAIL PROTECTED]
To: Michael P. Carel [EMAIL PROTECTED]; george Pitcher
[EMAIL PROTECTED]
Cc: php [EMAIL PROTECTED]
Sent: Wednesday, February 27, 2002 12:32 AM
Subject: Re: [PHP] header problem


 question, is this on a process page or on  a page that renders text?

 Jim Lucas
 - Original Message -
 From: Michael P. Carel [EMAIL PROTECTED]
 To: george Pitcher [EMAIL PROTECTED]
 Cc: php [EMAIL PROTECTED]
 Sent: Monday, February 25, 2002 5:44 PM
 Subject: Re: [PHP] header problem


  Thank you George you are right, Im looking for a redirector once details
  have been checked in the form and written in the database, but how can i
 do
  it what whould be the second option? i 've searching for javascript
  redirector but i cant find one. Could you please help me im stuck here.
 
 
 
  Regards,
  Mike
 
 
  - Original Message -
  From: george Pitcher [EMAIL PROTECTED]
  To: Michael P. Carel [EMAIL PROTECTED]
  Sent: Friday, February 22, 2002 5:44 PM
  Subject: Re: [PHP] header problem
 
 
   Michael,
  
   You cannot have any 'displayed' text prior to using the header
function.
   You'll need to do this another way.
  
   Are you looking for automatic submission after completing a form or
   redirection once details have been checked.
  
   The first one is only possible with client-side scripting such as
   javascript (and I'm not sure if it's possible there). The second
option
   is easy.
  
   HTH
  
   George
  
  
  
   On Fri, 2002-02-22 at 09:28, Michael P. Carel wrote:
Hi ,
   
I  have a problem in using the Header() function. I want to
  automatically
redirect the page into another php script after a form completion
but
 im
receiving this error Warning: Cannot add header information -
headers
already sent by ..
   
Heres the script line:
   
header(Location: 8D_Anaform_Admin.php?action=form);
   
Please help im stuck here.
   
   
   
   
Regards,
Mike
   
   
  
  
  
   _
   Do You Yahoo!?
   Get your free @yahoo.com address at http://mail.yahoo.com
 
 
  --
  PHP General Mailing List (http://www.php.net/)
  To unsubscribe, visit: http://www.php.net/unsub.php
 
 


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


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




Re: [PHP] header problem

2002-02-25 Thread Michael P. Carel

Thank you George you are right, Im looking for a redirector once details
have been checked in the form and written in the database, but how can i do
it what whould be the second option? i 've searching for javascript
redirector but i cant find one. Could you please help me im stuck here.



Regards,
Mike


- Original Message -
From: george Pitcher [EMAIL PROTECTED]
To: Michael P. Carel [EMAIL PROTECTED]
Sent: Friday, February 22, 2002 5:44 PM
Subject: Re: [PHP] header problem


 Michael,

 You cannot have any 'displayed' text prior to using the header function.
 You'll need to do this another way.

 Are you looking for automatic submission after completing a form or
 redirection once details have been checked.

 The first one is only possible with client-side scripting such as
 javascript (and I'm not sure if it's possible there). The second option
 is easy.

 HTH

 George



 On Fri, 2002-02-22 at 09:28, Michael P. Carel wrote:
  Hi ,
 
  I  have a problem in using the Header() function. I want to
automatically
  redirect the page into another php script after a form completion but im
  receiving this error Warning: Cannot add header information - headers
  already sent by ..
 
  Heres the script line:
 
  header(Location: 8D_Anaform_Admin.php?action=form);
 
  Please help im stuck here.
 
 
 
 
  Regards,
  Mike
 
 



 _
 Do You Yahoo!?
 Get your free @yahoo.com address at http://mail.yahoo.com


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




[PHP] header problem

2002-02-22 Thread Michael P. Carel

Hi ,

I  have a problem in using the Header() function. I want to automatically
redirect the page into another php script after a form completion but im
receiving this error Warning: Cannot add header information - headers
already sent by ..

Heres the script line:

header(Location: 8D_Anaform_Admin.php?action=form);

Please help im stuck here.




Regards,
Mike


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




Re: [PHP] header problem

2002-02-22 Thread Rasmus Lerdorf

You can't redirect after sending output unless you use Javascript or some
other weirdness.  Redirections are done before any output.

-Rasmus

On Fri, 22 Feb 2002, Michael P. Carel wrote:

 Hi ,

 I  have a problem in using the Header() function. I want to automatically
 redirect the page into another php script after a form completion but im
 receiving this error Warning: Cannot add header information - headers
 already sent by ..

 Heres the script line:

 header(Location: 8D_Anaform_Admin.php?action=form);

 Please help im stuck here.




 Regards,
 Mike


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



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




[PHP] Header problem

2002-01-14 Thread Petr Rezek

Here is my question.
I wrote a script, which gets parameters from db about document (location on
disc, hashed filename and original filename). Then script open this file a
send it to user.

I use this headers

Header(Content-Type: application/download\n);
Header(Content-Disposition: attachment;filename=\name_of_file\);
Header(Content-Transfer-Encoding: binary);

On Windows it works good, but on Mac it doesn't accept name_of_file and try
save this file with name of script.
What is wrong ? Do you have any idea ??

If I used:
Header(Content-Disposition: filename=\jmeno_souboru\);
then this script doesn't work also on Windows with Mozilla. Is there any
error in MSIE on Mac, isn't it ?

Thank you for any idea
Petr





-- 
PHP General 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] Header problem

2002-01-14 Thread Krzysztof Kocjan

It seems to be bug in IE/Netscape/Other www browser on Mac, that's all. 
Header wasn't correct interpreted. I had similar problem with NETSCAPE 6 
on Windows. I hope they will correct it shortly.

Krzysztof

Petr Rezek wrote:

 Here is my question.
 I wrote a script, which gets parameters from db about document (location on
 disc, hashed filename and original filename). Then script open this file a
 send it to user.
 
 I use this headers
 
 Header(Content-Type: application/download\n);
 Header(Content-Disposition: attachment;filename=\name_of_file\);
 Header(Content-Transfer-Encoding: binary);
 
 On Windows it works good, but on Mac it doesn't accept name_of_file and try
 save this file with name of script.
 What is wrong ? Do you have any idea ??
 
 If I used:
 Header(Content-Disposition: filename=\jmeno_souboru\);
 then this script doesn't work also on Windows with Mozilla. Is there any
 error in MSIE on Mac, isn't it ?
 
 Thank you for any idea
 Petr
 
 
 
 
 
 



--
Bojkot dokumentow w formacie Worda?
http://komputery.interia.pl/id/arch/www/wysinf_id=218065


-- 
PHP General 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] Header Problem...

2001-03-26 Thread E K L

Hi all,

could any one tell me that how do I go to a specific URL using php 
command.At the same time, I would like to pass the variable to the page.
I used header to do it but failed, with the error message:-

Warning: Cannot add header information - headers already sent by (output 
started at /usr/local/apache/htdocs/traName_use.php:2) in 
/usr/local/apache/htdocs/traName_use.php on line 3

Warning: Cannot add header information - headers already sent by (output 
started at /usr/local/apache/htdocs/traName_use.php:2) in 
/usr/local/apache/htdocs/traName_use.php on line 4

Warning: Cannot add header information - headers already sent by (output 
started at /usr/local/apache/htdocs/traName_use.php:2) in 
/usr/local/apache/htdocs/traName_use.php on line 26




And our code is as below:-

?php
header("Pragma : no-cache ");
header("Cache-Control :no-cache,must-revalidate");

$db=mysql_connect("localhost","root","123456");
mysql_select_db("test",$db);
$query="select trade_name_c
from confirm_member_info
where  trade_name_c = '$tradeName'";
$result=mysql_query($query,$db);
$row=mysql_fetch_row($result);

if($row[0]==$tradeName)
{
//echo "Sorry, the Trade Name b$tradeName/b has been usedBr";
//echo "Please Choose other Trade NameBR";
//echo "Click a href='mysignup_1.php'here/a to back.";
header("Location: http://192.168.0.1/mysignup_1.php");
}
else
{
//echo "Your Trade Name and password has been accepttedbr";
//echo "Click to proceed.";
//input type='hidden' name='introducer' value='$introducer'
header("Location: http://www.hotmail.com");
}
?
input type="hidden" name="tradeName" value="?$tradeName?"
input type="hidden" name="password" value="?$password?"
input type="hidden" name="MotherName" value="?$MotherName?"


I tried to use hidden input type to pass the value, but can it work without 
form and submit button??

I would appreaciate if you could give me suggestions and advice.

thanks


_
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.


-- 
PHP General 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] Header Problem...

2001-03-26 Thread Renze Munnik

There may not be any headers before you use the 'header' statement.
The header("Location:...") should be the first output you send. You
might want to consider moving the two 'anti-cache' headers after the
header("Location;...") statement.

RenzE.


On Mon, Mar 26, 2001 at 11:06:11PM +0800, E K L wrote:
 Hi all,
 
 could any one tell me that how do I go to a specific URL using php 
 command.At the same time, I would like to pass the variable to the page.
 I used header to do it but failed, with the error message:-
 
 Warning: Cannot add header information - headers already sent by (output 
 started at /usr/local/apache/htdocs/traName_use.php:2) in 
 /usr/local/apache/htdocs/traName_use.php on line 3
 
 Warning: Cannot add header information - headers already sent by (output 
 started at /usr/local/apache/htdocs/traName_use.php:2) in 
 /usr/local/apache/htdocs/traName_use.php on line 4
 
 Warning: Cannot add header information - headers already sent by (output 
 started at /usr/local/apache/htdocs/traName_use.php:2) in 
 /usr/local/apache/htdocs/traName_use.php on line 26
 
 
 
 
 And our code is as below:-
 
 ?php
 header("Pragma : no-cache ");
 header("Cache-Control :no-cache,must-revalidate");
 
 $db=mysql_connect("localhost","root","123456");
 mysql_select_db("test",$db);
 $query="select trade_name_c
 from confirm_member_info
   where  trade_name_c = '$tradeName'";
 $result=mysql_query($query,$db);
 $row=mysql_fetch_row($result);
 
 if($row[0]==$tradeName)
 {
 //echo "Sorry, the Trade Name b$tradeName/b has been usedBr";
 //echo "Please Choose other Trade NameBR";
 //echo "Click a href='mysignup_1.php'here/a to back.";
 header("Location: http://192.168.0.1/mysignup_1.php");
 }
 else
 {
 //echo "Your Trade Name and password has been accepttedbr";
 //echo "Click to proceed.";
 //input type='hidden' name='introducer' value='$introducer'
 header("Location: http://www.hotmail.com");
 }
 ?
 input type="hidden" name="tradeName" value="?$tradeName?"
 input type="hidden" name="password" value="?$password?"
 input type="hidden" name="MotherName" value="?$MotherName?"
 
 
 I tried to use hidden input type to pass the value, but can it work without 
 form and submit button??
 
 I would appreaciate if you could give me suggestions and advice.
 
 thanks
 
 
 _
 Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
 
 
 -- 
 PHP General 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 General 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] Header Problem

2001-03-21 Thread Pierre-Yves Lemaire

Hello,
Yes this should work, but if like me, you still have no redirection and
you are working with IE 4.0, put exit; after header.
$URL="domain.com";
header ("Location: Http://www.$URL/members/index.php");
exit;

I have not seen this anywhere, but putting exit; after a redirection
was the only way to get my redirection with header to work.

py

- Original Message -
From: Rasmus Lerdorf [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Wednesday, March 21, 2001 7:45 AM
Subject: Re: [PHP] Header Problem


 Should work just fine.

 On Wed, 21 Mar 2001 [EMAIL PROTECTED] wrote:

  Hi,
 
  I`m having whats probably a very basic problem but just can`t get my
head
  around it this late in the day, anyone have any idea why this won`t
work?
 
  $URL="domain.com";
 
  header ("Location: Http://www.$URL/members/index.php");
 
  $URL changes so I can`t write it directly into the header line, anyone?
 
  --
  PHP General 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 General 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 General 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] Header Problem

2001-03-21 Thread almir

are you using cookies together with header , i had problems with that
-almir

[EMAIL PROTECTED] schrieb im Newsbeitrag
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi,

 I`m having whats probably a very basic problem but just can`t get my head
 around it this late in the day, anyone have any idea why this won`t work?

 $URL="domain.com";

 header ("Location: Http://www.$URL/members/index.php");

 $URL changes so I can`t write it directly into the header line, anyone?

 --
 PHP General 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 General 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] Header Problem

2001-03-21 Thread Keith Vance

What happens when it doesn't work, any error messages?
Try:
header ("Location: http://www." . $URL . "/members/index.php");

or

$loc = "Location: http://www." . $URL . "/members/index.php";
header ($loc);

The first suggestion should work.

K E I T H  V A N C E
Software Engineer
n-Link Corporation

On Wed, 21 Mar 2001, almir wrote:

 are you using cookies together with header , i had problems with that
 -almir

 [EMAIL PROTECTED] schrieb im Newsbeitrag
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Hi,
 
  I`m having whats probably a very basic problem but just can`t get my head
  around it this late in the day, anyone have any idea why this won`t work?
 
  $URL="domain.com";
 
  header ("Location: Http://www.$URL/members/index.php");
 
  $URL changes so I can`t write it directly into the header line, anyone?
 
  --
  PHP General 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 General 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 General 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] Header Problem

2001-03-20 Thread KPortsmout

Hi,

I`m having whats probably a very basic problem but just can`t get my head 
around it this late in the day, anyone have any idea why this won`t work?

$URL="domain.com";

header ("Location: Http://www.$URL/members/index.php");

$URL changes so I can`t write it directly into the header line, anyone?

-- 
PHP General 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]