The closest thing I have found to a solution is this link on stack overflow: output-buffering-with-php-headers
He is doing the same thing I am trying to accomplish. When I implement his code I get this error: “BEGIN:VCARD VERSION:3.0 N:Stone;Kenneth;R.;;; FN:Kenneth R. Stone TITLE:Partner PHOTO;VALUE=URL;TYPE=JPG:https://www.baileyglasser.com/images/attorney_photos/kstone.png ORG:Hefner, Stark & Marois, LLP TEL;WORK;VOICE: TEL;WORK;FAX: EMAIL;TYPE=PREF;INTERNET:[email protected] ADR;WORK;ENCODING=QUOTED-PRINTABLE:;;2150 River Plaza Drive=0D=0ASuite 450;Sacramento;CA;95833;United States; URL;TYPE=WORK:https://www.baileyglasser.com END:VCARD Warning: Cannot modify header information – headers already sent by (output started at /var/www/hsm.bothwip2013.com/wp-includes/link-template.php:1640) in /var/www/hsm.bothwip2013.com/wp-content/themes/Featherchild/attorney-vcard.php on line 59 Warning: Cannot modify header information – headers already sent by (output started at /var/www/hsm.bothwip2013.com/wp-includes/link-template.php:1640) in /var/www/hsm.bothwip2013.com/wp-content/themes/Featherchild/attorney-vcard.php on line 60 “
Here is my code:
<?php
ob_start();
require "code/dbconn.php";
if ($attorney_id) {
$query="SELECT a.*, l.* FROM attorneys AS a JOIN lawfirm AS l ON l.id = a.attorney_office WHERE attorney_id = $attorney_id";
$result=mysql_query($query);
$myrow = mysql_fetch_array($result);
$seoname=$myrow["seo_title"];
$first=$myrow["attorney_fname"];
$middle=$myrow["attorney_mname"];
$last=$myrow["attorney_lname"];
$attorney_email=$myrow["attorney_email"];
$attorney_office=$myrow["attorney_office"];
$tel=preg_replace ('/^(\d+)\.(\d+)\.(\d+)$/', '($1) $2-$3', $myrow["attorney_tel"]);
$fax=preg_replace ('/^(\d+)\.(\d+)\.(\d+)$/', '($1) $2-$3', $myrow["attorney_fax"]);
$attorney_title=$myrow["attorney_title"];
if ($middle) {
$fullname = (isset ($middle)) ? "$first $middle $last" : "$first $last"; }
if (!$middle) {
$fullname = (isset ($middle)) ? "$first $last" : "$first $last"; }
$filename = preg_replace ('/ +/', '_', $fullname);
$filename = preg_replace ('/[^a-z_]+/i', '', $filename);
$photo = $myrow["attorney_photo"];
$path = "https://www.baileyglasser.com/images/attorney_photos/";
$office = $myrow["office"];
$address =$myrow["address"];
$address2 =$myrow["address2"];
$city =$myrow["city"];
$state =$myrow["state"];
$zip =$myrow["zip"];
$country ="United States";
$query1 = "SELECT * FROM titles WHERE $attorney_title=title_id ";
$result1 = mysql_query($query1);
$myrow1 = mysql_fetch_array($result1);
$title = $myrow1["title_name"];
print <<<END
BEGIN:VCARD
VERSION:3.0
N:$last;$first;$middle;;;
FN:$fullname
TITLE:$title
PHOTO;VALUE=URL;TYPE=JPG:$path$photo
ORG:$office
TEL;WORK;VOICE:$tel
TEL;WORK;FAX:$fax
EMAIL;TYPE=PREF;INTERNET:$attorney_email
ADR;WORK;ENCODING=QUOTED-PRINTABLE:;;$address=0D=0A$address2;$city;$state;$zip;$country;
URL;TYPE=WORK:https://www.baileyglasser.com
END:VCARD
END;
$output = ob_get_contents();
header('Content-Type: text/x-vcard');
header('Content-Disposition: attachment; filename=vCard_' . $filename . '.vcf');
return $output;
exit();
}
?>
Thanks for any further assistance.