RE: [PHP] file
| From: | Rich Gray | Date: | Fri, 28 Mar 2003 10:36:22 +0000 |
| Subject: | RE: [PHP] file | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-141404@lists.php.net to get a copy of this message | ||
> hi all!
>
> i have a simple program to open and write a file.
> but the file is not getting created.
> can anyone please spot the mistake?
> giving the code below.
>
> thanks a lot,
> diksha.
>
> <?php
> echo"hi?how are u doing??";
> $fp = fopen ("sandrew.html", "w");
> string="<html><head><title>hi</title></head><body>i am
>
> fine</body></html>";
> $contents=fwrite($fp,string);
> echo "'$contents'";
> fclose($fp);
> ?>
Hi Diksha
Some comments...
. Your string variable needs to be defined and referenced as $string not
just string - unless this is a typo in your post
. fwrite() returns an int - you are assigning this int to $contents - what
exactly are you expecting $contents to be set to?
. Does your user or web server process have the permissions to create files
in the directory?
. What does readfile('sandrew.html'); after your fclose($fp) return?
HTH
Rich