Problems with else.
Posted: Thu Aug 29, 2002 5:47 am
Hi
I am writing a small test php script to apdate a text file i have on my server. I am having a problem with printing a success message or a failure message using else. Any advice on the code would be appreciated.
Even how the code looks or any advice on layout.
Something else, how would I make sure that the latest addition would go to the top of the txt file and not the bottom.
Thx again guys.
I am writing a small test php script to apdate a text file i have on my server. I am having a problem with printing a success message or a failure message using else. Any advice on the code would be appreciated.
Even how the code looks or any advice on layout.
Something else, how would I make sure that the latest addition would go to the top of the txt file and not the bottom.
Thx again guys.
Code: Select all
<html>
<head>
<title>News Receive</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<?php
function WriteToFile ($name, $email, $news) {
$TheFile = news.txt;
$OPEN = fopen ($news.txt, "a");
if ($Open) {
fWrite ($Open,"$name\t$email\t$name\n");
fclose ($open);
$Worked = TRUE;
} else {
$Worked = FALSE;
}
return $Worked;
}
$Callfunction = WriteToFile ($Arrayї"name"], $Arrayї"email"], $Arrayї"news"]);
Print ("Successful Update -- <BR> $Array{news}\n");
} else {
Print ("Please Re-submit");
?>
</body>
</html>