[Scottish] PHP configuration problem ?

george scottish at mailman.lug.org.uk
Mon Nov 11 22:03:01 2002


  This should work.

<?php

$outputstring=3D date("H:i, jS F")."\t".$criffel." Criffel \t".$deuchars."=
=20
Deuchars \t".$hefe." Erdinger\t Price: =A3".$subtotal." plus=20
VAT\t".$address."\n";
         $targetfile=3D"$DOCUMENT_ROOT/phptext/beer.txt";
         $fp =3D fopen($targetfile, "a+");
         if (!$fp)
          { echo "<strong>Your order could not be processed at this time.  =
 ";
                   echo    "It's the dilithium crystals. They're=20
knackered.</strong>";
           exit;
          }

         fwrite($fp, $outputstring);
         fclose($fp);

?>

  George

At 21:45 11/11/2002 +0000, you wrote:
>Hi.
>
>This probably a bit OT, but I'm not sure if it's a problem with my php=20
>code itself, or with the way I've got it and Apache configured. (The basic=
=20
>Mandrake 8 out of the box configuration in each case).
>
>I'm trying to teach myself a bit of php, but I'm having problems getting=20
>it to write stuff to files with fopen() and fwrite(). I don't get a=20
>"permission denied", or "file not found " message: it seems to work=20
>perfectly, except that nothing gets added to the file.
>
>I've chmodded the permissions on the target directory and target file to=20
>777, so there shouldn't be any problems with file permissions.
>
>The type of code which fails is:
>
>
>
>         $outputstring=3D date("H:i, jS F")."\t".$criffel." Criffel=20
> \t".$deuchars." Deuchars \t".$hefe." Erdinger\t Price: =A3".$subtotal."=20
> plus VAT\t".$address."\n";
>         $targetfile=3D"$DOCUMENT_ROOT/phptext/beer.txt";
>         $fp =3D fopen($targetfile, "a+");
>         if (!$fp)
>         { echo "<strong>Your order could not be processed at this time.  =
 ";
>                   echo    "It's the dilithium crystals. They're=20
> knackered.</strong>";}
>                 exit;
>         fwrite($targetfile, $outputstring);
>         fclose($targetfile);
>
>If I manually enter some text into the output file, I've no problems=20
>reading it out with php.
>
>Any idea where I'm going wrong ?
>
>
>*********************************************
>Tom Shearer
>
>Email: mail@tomshearer.free-online.co.uk
>
>_______________________________________________
>Scottish mailing list
>Scottish@mailman.lug.org.uk
>http://mailman.lug.org.uk/mailman/listinfo/scottish