
July 31st, 2004, 05:39 PM
|
|
Registered User
|
|
Join Date: Apr 2007
Posts: 22,309
Time spent in forums: < 1 sec
Reputation Power: 24
|
|
|
creating a news system with php - part 1
osX running apache 2.0.50 and PHP 4.3.8
i've been following the tutorial, and making changes where necessary. however, i've got a bit stuck. when i submit my news, i get the following message:
Warning: fopen(news.txt): failed to open stream: Permission denied in /users/matt_busher/sites/news/addnews.php on line 26
error:
cannot open file
not sure what i've done wrong so below is the code...
php Code:
Original
- php Code |
|
|
|
<?php if($_POST['submit']) { if($_POST['password'] == 'password') { if(!$_POST['name']) { echo "<h3><b>error:</b></h3> <p>you must enter a name</p>"; } if(!$_POST['news']) { echo "<h3><b>error:</b></h3> <p>you must enter some news</p>"; } if(strstr($_POST['name'], "|")) { echo "<h3><b><error:/b></h3> <p>name cannot contain <b>|</b></p>"; } if(strstr($_POST['news'], "|")) { echo "<h3><b>error</b></h3> <p>news cannot contain <b>|</b></p>"; } $fp = fopen('news.txt', 'a'); if(!$fp) { echo "<h3><b>error:</b></h3> <p>cannot open file</p>"; } $line = date("dd.mm.yy") . "|" . $_POST['name']; $line .= "|" . $_POST['news']; $line .= "rn"; echo "<h3><b>error:</b></h3> <p>cannot close file</p>"; } echo "<h3><b>action successful:</b></h3> <p>your news has been submitted</p>"; } else { echo "<h3><b>error:</b></h3> <p>bad password</p>"; } } ?>
much appreciated
|