Thanks for the pointers guys.
The revised code (it works) is:
$fp2 = "C:\\inetpub\\wwwroot\\packtracker\\LSE\\".$cr.".txt";
if (!$fp2 = fopen($fp2, 'w')) {
print "Cannot open the bloody file ($fp2)";
exit;
}
if (!fwrite($fp2, $content)) {
print "Cannot write to file ($fp2)";
exit;
}
fclose($fp2);
rename($cr.".txt",$cr.".doc");
It may be of use to someone else.
Cheers
George
> -----Original Message-----
> From: Svensson, B.A.T. (HKG) [mailto:[EMAIL PROTECTED]
> Sent: 9 September 2003 3:54 pm
> To: George Pitcher
> Subject: RE: [PHP-WIN] Problem writing to a file
>
>
> Try us the file pointer to write to the file
> instead of the file name, then it should work.
>
> > -----Original Message-----
> > From: George Pitcher [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, September 09, 2003 4:38 PM
> > To: [EMAIL PROTECTED]
> > Subject: [PHP-WIN] Problem writing to a file
> >
> >
> > Hi all,
> >
> > I'm having a problem writing to a text file.
> >
> > This is the error message:
> > = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
> > Warning: fwrite():
> > supplied argument is not a valid stream resource in
> > C:\Inetpub\wwwroot\packtracker\lse\pub_req_start2.php on line 276
> > Cannot write to file
> > (C:\inetpub\wwwroot\packtracker\LSE\IR201_1770.txt)
> > = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
> >
> > This is the code:
> > -----------------------------------------------------------------
> > $fp2 = "C:\\inetpub\\wwwroot\packtracker\\LSE\\".$cr.".txt";
> > $fp3 = "C:\\inetpub\\wwwroot\packtracker\\LSE\\".$cr.".doc";
> > $fn1 = file_get_contents("pub_letter.txt");
> > // replace some of the content placeholders with variables <<<
> > $content = $fn1;
> > if (!$fp = fopen($fp2, 'w')) {
> > print "Cannot open the bloody file ($fp2)";
> > exit;
> > }
> > // chmod($fp2,222); tried this - no effect
> > if (!fwrite($fp2, $content)) {
> > print "Cannot write to file ($fp2)";
> > exit;
> > }
> > rename($fp2,$fp3);
> > fclose($fp3);
> > fclose($fp2);
> > if($contact_route == 'Email' | $contact_route == 'email') {
> > ----------------------------------------------------------------
> >
> > So as you can see, I load a text file (actually its RTF saved as text),
> > parse it then write it to an open txt file, then rename that as
> a Word doc.
> >
> > I'm running this on NT with PHP 4.3.2. The folder has write
> access for the
> > web user.
> >
> > Any suggestions?
> >
> > Cheers
> >
> > George
> >
> > ===
> >
> > George Pitcher
> > HERON Technical Manager
> > Ingenta plc
> > 23-38 Hythe Bridge Street, Oxford, OX1 2ET
> > T +44 (0)1865 799051 direct
> > T +44 (0)1865 799000 switchboard
> > F +44 (0)1865 799134
> > E [EMAIL PROTECTED]
> >
> > www.ingenta.com
> >
> > Ingenta: Empowering the exchange of academic and professional content
> > online.
> >
> > --
> > PHP Windows Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
--
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php