I'm trying to populate an .rtf file and have the finished product open in word. I think that it's all populating fine... I get the results back with all the .rtf mumbo jumbo code and can see that my data is included.... but it just opens in a browser and the browser doesn't know what to do with it.
The book that I am using the code from does make mention of header problems with some browsers and that you may have to modify the code, but I don't have any idea where to start.... there is no information on the publishers site.
Here's how it starts now...
<?php
header("Content-type: application/msword");
header("Content-Disposition: inline, filename=slotaletter1.rtf");
echo("<html><head><title>Untitled Document</title></head><body>");
$dbcnx = mysql_connect("localhost", "usxxxxx", "xxxxxxx");
** It then grabs the info from the database, parses it etc... then...
$filename = "slotaletter1.rtf";
$fp = fopen ( $filename, "r" );
//read our template into a variable
$output = fread( $fp, filesize( $filename ) );
fclose ( $fp );
// replace the place holders in the template with our data
$output = str_replace( "<<sal>>", $salutation, $output );
$output = str_replace( "<<first>>", $firstname, $output );
$output = str_replace( "<<last>>", $lastname, $output );
$output = str_replace( "<<address1>>", $address1, $output );
$output = str_replace( "<<address2>>", $address2, $output );
$output = str_replace( "<<city>>", $city, $output );
$output = str_replace( "<<state>>", $state, $output );
$output = str_replace( "<<zip>>", $state, $output );
$output = str_replace( "<<day>>", $dateday, $output );
$output = str_replace( "<<date>>", $date, $output );
// send the generated document to the browser
echo $output;
It all seems to work fine, but the browser displays this (see below)... which seems to be right, it's my letter, fully populated with the .rtf formatting included... except word is supposed to open... and then this output is what opens in word... instead of the browser...
{\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1033\deflangfe1033{\fonttbl{\f0\from
an\fcharset0\fprq2{*\panose 02020603050405020304}Times New Roman;}{\f28\fswiss\fcharset128\fprq2{*\panose 020b0604020202020204}Arial Unicode MS;} {\f418\fswiss\fcharset128\fprq2 @Arial Unicode MS;}{\f419\froman\fcharset238\fprq2 Times New Roman CE;}{\f420\froman\fcharset204\fprq2 Times New Roman Cyr;}{\f422\froman\fcharset161\fprq2 Times New Roman Greek;} {\f423\froman\fcharset162\fprq2 Times New Roman Tur;}{\f424\froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f425\froman\fcharset178\fprq2 Times New Roman (Arabic);}{\f426\froman\fcharset186\fprq2 Times New Roman Baltic;} {\f645\fswiss\fcharset0\fprq2 Arial Unicode MS Western;}{\f643\fswiss\fcharset238\fprq2 Arial Unicode MS CE;}{\f644\fswiss\fcharset204\fprq2 Arial Unicode MS Cyr;}{\f646\fswiss\fcharset161\fprq2 Arial Unicode MS Greek;} {\f647\fswiss\fcharset162\fprq2 Arial Unicode MS Tur;}{\f648\fswiss\fcharset177\fprq2 Arial Unicode MS (Hebrew);}{\f649\fswiss\fcharset178\fprq2 Arial Unicode MS (Arabic);}{\f650\fswiss\fcharset186\fprq2 Arial Unicode MS Baltic;} {\f3765\fswiss\fcharset0\fprq2 @Arial Unicode MS Western;}{\f3763\fswiss\fcharset238\fprq2 @Arial Unicode MS CE;}{\f3764\fswiss\fcharset204\fprq2 @Arial Unicode MS Cyr;}{\f3766\fswiss\fcharset161\fprq2 @Arial Unicode MS Greek;} {\f3767\fswiss\fcharset162\fprq2 @Arial Unicode MS Tur;}{\f3768\fswiss\fcharset177\fprq2 @Arial Unicode MS (Hebrew);}{\f3769\fswiss\fcharset178\fprq2 @Arial Unicode MS (Arabic);}{\f3770\fswiss\fcharset186\fprq2 @Arial Unicode MS Baltic;}} {\colortbl;\red0\green0\blue0;\red0\green0\blue255
;\red0\green255\blue255;\red0\green255\blue0;\red2
55\green0\blue255;\red255\green0\blue0;\red255\gre
en255\blue0;\red255\green255\blue255;\red0\green0\
blue128;\red0\green128\blue128;\red0\green128\blue
0; \red128\green0\blue128;\red128\green0\blue0;\red12
8\green128\blue0;\red128\green128\blue128;\red192\
green192\blue192;}{\stylesheet{\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustri
ght\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfen
p1033 \snext0 Normal;}{*\cs10 \additive Default Paragraph Font;}{\s15\ql \li0\ri0\sb100\sa100\sbauto1\saauto1\widctlpar\asp
alpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1033\langfe1033\loch\f28\hich\af28\dbch\
af28\cgrid\langnp1033\langfenp1033 \sbasedon0 \snext15 Normal (Web);}{*\cs16 \additive \b \sbasedon10 Strong;}{\s17\ql \li720\ri0\widctlpar\aspalpha\aspnum\faauto\adjust
right\rin0\lin720\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfen
p1033 \sbasedon0 \snext17 Body Text 2;}}{\info{\title June 18, 2003}{\author Jason Ulrich}{\operator Jason Ulrich}{\creatim\yr2003\mo6\dy18\hr15\min11}{\revt
im\yr2003\mo6\dy18\hr15\min55}{\version3} {\edmins44}{\nofpages1}{\nofwords0}{\nofchars0}{*
\company KWMU}{\nofcharsws0}{\vern8269}}\margl1440\margr144
0\margt1980 \widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noul
trlspc\dntblnsbdb\nospaceforul\formshade\horzdoc\d
gmargin\dghspace120\dgvspace180 \dghorigin1440\dgvorigin1980\dghshow2\dgvshow2\jex
pand\viewkind1\viewscale75\pgbrdrhead\pgbrdrfoot\s
plytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltb
aln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule \fet0\sectd \binfsxn7\binsxn7\psz1\linex0\headery1008\footery1
008\endnhere\titlepg\sectlinegrid360\sectdefaultcl
{*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang{\
pntxta . }}{*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhan
g{\pntxta .}}{*\pnseclvl3 \pndec\pnstart1\pnindent720\pnhang{\pntxta . }}{*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhan
g{\pntxta )}}{*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang
{\pntxtb (}{\pntxta )}}{*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnha
ng{\pntxtb (}{\pntxta )}} {*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang{\
pntxtb (}{\pntxta )}}{*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnha
ng{\pntxtb (}{\pntxta )}}{*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhan
g{\pntxtb (}{\pntxta )}}\pard\plain \ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustri
ght\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfen
p1033 {\field{*\fldinst { TIME \@ "MMMM d, yyyy" }}{\fldrslt {\lang1024\langfe1024\noproof June 18, 2003}}}{ \par \par Ms. Jean Ponzi\line 3617 Grandel Square\line \par St. Louis, MO MO }{\loch\af28\hich\af28\dbch\af28 \par }{ \par \par Dear Ms. Ponzi: \par \par Thank you for agreeing to participate in KWMU's call-in program, ST. LOUIS ON THE AIR. You are scheduled to be on: \par \line \tab Tuesday \par }\pard\plain \s17\ql \li720\ri0\widctlpar\aspalpha\aspnum\faauto\adjust
right\rin0\lin720\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfen
p1033 {June 17, 2003day \par 11:00 a.m. \par }\pard\plain \ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustri
ght\rin0\lin0\itap0 \fs24\lang1033\langfe1033\cgrid\langnp1033\langfen
p1033 { \par While the program will air from 11:00 a.m.-noon, it is important that you are in the studio no later than 10:45 a.m. \par \par In the event that you should need to cancel, so that KWMU can make other arrangements, it is important that you call: }{\cs16\b 516-6163}{ during business hours, and after hours: }{\cs16\b 826-5020}{. \par \par Please find enclosed a map to the KWMU studios located in Lucas Hall on the campus of the University of Missouri-St. Louis. Please park in Garage 'N' as indicated on the m ap. Also, please find enclosed a parking permit that should be placed in the rear driver\rquote s side window, or your car may be ticketed. \par \par We look forward to talking with you and look forward to your participation in ST. LOUIS ON THE AIR. \par \par Sincerely, \par \~ \par \par \par \par Mary Edwards\line Production Manager\line KWMU-FM \par \par }}