I'm trying to write date to an rtf file take from a database, but I get an error in opening the actual file. Here is my code would really appreciate some help here i'ts driving me crazy
<?
$header='{\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{*\panose 02020603050405020304}Times New Roman;}{\f1\fswiss\fcharset0\fprq2{*\panose 020b0604020202020204}Arial;}
{\f129\froman\fcharset238\fprq2 Times New Roman CE;}{\f130\froman\fcharset204\fprq2 Times New Roman Cyr;}{\f132\froman\fcharset161\fprq2 Times New Roman Greek;}{\f133\froman\fcharset162\fprq2 Times New Roman Tur;}
{\f134\froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f135\froman\fcharset178\fprq2 Times New Roman (Arabic);}{\f136\froman\fcharset186\fprq2 Times New Roman Baltic;}{\f137\fswiss\fcharset238\fprq2 Arial CE;}
{\f138\fswiss\fcharset204\fprq2 Arial Cyr;}{\f140\fswiss\fcharset161\fprq2 Arial Greek;}{\f141\fswiss\fcharset162\fprq2 Arial Tur;}{\f142\fswiss\fcharset177\fprq2 Arial (Hebrew);}{\f143\fswiss\fcharset178\fprq2 Arial (Arabic);}
{\f144\fswiss\fcharset186\fprq2 Arial Baltic;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;\red0\green0\blue128;
\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0
\fs24\lang3081\langfe1033\cgrid\langnp3081\langfenp1033 \snext0 Normal;}{*\cs10 \additive Default Paragraph Font;}}{\info{\title Company Name}{\author }{\operator }{\creatim\yr2002\mo3\dy27\hr20\min1}{\revtim\yr2002\mo3\dy27\hr20\min9}{\version1}
{\edmins8}{\nofpages1}{\nofwords0}{\nofchars0}{*\company }{\nofcharsws0}{\vern8247}}\paperw11906\paperh16838 \deftab4536\widowctrl\ftnbj\aenddoc\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\formshade\horzdoc\dgmargin\dghspace180\dgvspace180
\dghorigin1800\dgvorigin1440\dghshow1\dgvshow1\jexpand\viewkind1\viewscale100\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule \fet0\sectd
\linex0\endnhere\sectlinegrid360\sectdefaultcl {*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang{\pntxta .}}{*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang{\pntxta .}}{*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang{\pntxta .}}{*\pnseclvl4
\pnlcltr\pnstart1\pnindent720\pnhang{\pntxta )}}{*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}
{\pntxta )}}{*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}\pard\plain \ql \li0\ri0\widctlpar
\tx57\tx2700\tx5220\tx6840\tx8280\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang3081\langfe1033\cgrid\langnp3081\langfenp1033 {\f1\fs16 Company Name\tab Trading As\tab Status\tab Address\par';
$footer='{\f1\fs20\par}}';
print "opening default.db<br>\n";
$fp=fopen("default.db", 'r');
flock($fp, 2);
print "opening myfile.dat to store all info<br>\n";
$fp1=fopen("c:\inetpub/wwwroot/cgi-bin/taanz/myfile.rtf", 'w');
flock($fp1, 1);
fwrite($fp1,$header);
while(! feof ($fp))
{
$line = fgets($fp, 1024);
if($line == "") {
fwrite ($fp1,$footer);
break;
}
$line1=ltrim($line);
$splitup = explode("|", $line1);
$compname=$splitup[0];
$tradeas = $splitup[1];
$status = $splitup[11];
$location1=$splitup[2];
$location2=$splitup[3];
$membership=$splitup[12];
$suburb=$splitup[4];
$city=$splitup[5];
print "$compname $tradeas $status Member $location1, $location2, $city<br>\n";
fwrite($fp1,'\par'.$compname.'\tab'.$tradeas.'\tab'.$status.'\tab'.$location1.'\par');
}
flock($fp, 3);
flock($fp1, 3);
fclose($fp1);
fclose($fp);
print "Done<br>\n";
?>