Re: [PHP4BETA] Appending to the end of a file
| From: | rasmus@php.net | Date: | Thu, 01 Jan 1970 00:00:00 +0000 |
| Subject: | Re: [PHP4BETA] Appending to the end of a file | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-7383@lists.php.net to get a copy of this message | ||
> Ok heres my situation, I am trying to append to the end of a with a form,
> but when it appends it just appends it onto my last line of my file which
> already has data on it but i want it to go one more line down and then
> append. How can i do this?
>
> Here is my function and some code i am using:
>
> <?
>
> function append_file($filename, $contents)
>
> if ($fp = fopen($filename, "a"))
>
> fwrite ($fp, stripslashes($contents));
> fclose($fp);
> return 1;
> }
> else { return 0; }
> };
>
> if ($submitButton == "appendfile")
>
> $rs = append_file( "$page", "$test", " ");
> echo "<a href=\"$page\">$page</A><BR> ";
>
> ?>
append_file($page,'\n'.$contents);
(You really shouldn't put quotes around variables by themselves like that)
-Rasmus