PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
$filename = "/home/webkin/public_html/news.php";
$username = $_POSTїusername];
$usernews = $_POSTїusernews];
if ($username == "") {
header( "Location: newssubmit.php");
}
if ($usernews == "") {
header( "Location: newssubmit.php");
}
$addtofile = "";
$addtofile .= "$username says:<br>/n
$usernews <br>";
$addtofile .= "-- date(Mjy)";
$filepointer = @fopen($filename, "W+") or die("couldnt open file");
@fwrite($filepointer, $addtofile) or die("Couldn't add news to $filename");
$msg = "<p>News was successfully added to $filename.</p>";
fclose($filename);
also, could anyone tell me what the @ symbol does in front of a function? It was in my PHP fast and easy web development book, so i just wrote it the same way... hoping it would work, i've tried everything that i can think of.
Try changing the "W+" to "w+", PHP is sometimes grouchy about the case. If that doesn't work, try taking out the @ and the or die() so that it looks like this:
What the @ sign does is suppress any error that PHP might try to give. Then by adding the "or die("couldnt open file")" it will automatically print out "couldn't open file" if there is any error.