Jump to content

PHP Headers (Some way to redirect them?)


thomasw_lrd

Recommended Posts

I'm trying to create a vcard from our database, but I keep running into headers already sent error.

 

Warning: Cannot modify header information - headers already sent by (output started at  in  on line 102 Warning: Cannot modify header information - headers already sent by (output started at ) in  on line 103

 

I understand why the error is occurring, but is there any way around it?  I want to create a downloadable vcard on the fly.  Any help would be appreciated.

 

 

Link to comment
Share on other sites

You can only output one content-type per http request.

 

For the http request for your web page, you cannot switch in the middle and try to download a vcard. You must put a link to the vcard that you want to be downloaded. If that vcard is dynamically created, the link would be to the .php script that creates the vcard. The .php script would retrieve the data from your database, output the correct content-type header, followed by the dynamically produced vcard data.

 

The one thing that you could do to your current code that would allow the vcard download to work, would prevent the web page up to that point from being output, so it would be kind of pointless.

 

 

Link to comment
Share on other sites

You can only output one content-type per http request.

 

For the http request for your web page, you cannot switch in the middle and try to download a vcard. You must put a link to the vcard that you want to be downloaded. If that vcard is dynamically created, the link would be to the .php script that creates the vcard. The .php script would retrieve the data from your database, output the correct content-type header, followed by the dynamically produced vcard data.

 

The one thing that you could do to your current code that would allow the vcard download to work, would prevent the web page up to that point from being output, so it would be kind of pointless.

 

That's exactly the solution I just thought of.  Thank you very much. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.