Hi guys, I'm doing a website for the condo and I'm having troubles with the new year party registration form. I think it's got something to do with my file handling. When I run it on my wamp server, it works fine. But when I upload it onto the internet it gives me a whole bunch of warnings:
Warning: fopen(newYearParty.txt) [function.fopen]: failed to open stream: Permission denied in /www/zymichost.com/i/n/d/inderasubangcondo/htdocs/newYrRegTq.php on line 18
Warning: fgets(): supplied argument is not a valid stream resource in /www/zymichost.com/i/n/d/inderasubangcondo/htdocs/newYrRegTq.php on line 19
Warning: fgets(): supplied argument is not a valid stream resource in /www/zymichost.com/i/n/d/inderasubangcondo/htdocs/newYrRegTq.php on line 20
Heres my code:
<?php
$nam = $_POST["nam"];
$block = $_POST["block"];
$floor = $_POST["floor"];
$house = $_POST["house"];
$adults = $_POST["adults"];
$children = $_POST["children"];
$guests = $_POST["guests"];
$nam = $_POST["nam"];
global $fn, $ft;
//set id and update total numbers
$fn = fopen("newYearParty.txt","a+");
$line1 = fgets($fn); $arr1 = explode(": ", $line1); //adults
$line2 = fgets($fn); $arr2 = explode(": ", $line2); //children
$line3 = fgets($fn); $arr3 = explode(": ", $line3); //guests
$line4 = fgets($fn); $arr4 = explode(": ", $line4); //total
$line4 = fgets($fn); //blank line
$numAdults = $arr1[1]+$adults;
$numChildren = $arr2[1]+$children;
$numGuests = $arr3[1]+$guests;
$numTotal = $numAdults+$numChildren+$numGuests;
$id = "nothing";
while(!feof($fn))
{ $line = fgets($fn); //id
$arr = explode(": ", $line);
$id = $arr[1] + 1; //get latest id and add 1 to it
for($i=0; $i<6; $i++)
{ $line = fgets($fn);
}
}
fclose($fn);
if($id == "nothing")
{ $id = "0";
}
//end of set id
//write to file
$line0 = "\r\nId: ".$id."\r\n";
$line1 = "Name: ".$nam."\r\n";
$line2 = "Unit: ".$block."-".$floor."-".$house."\r\n";
$line3 = "Adults: ".$adults."\r\n";
$line4 = "Children: ".$children."\r\n";
$line5 = "Guests: ".$guests."\r\n";
$fn = fopen("newYearParty.txt","a+");
fwrite($fn, $line0);
fwrite($fn, $line1);
fwrite($fn, $line2);
fwrite($fn, $line3);
fwrite($fn, $line4);
fwrite($fn, $line5);
fclose($fn);
//end of write to file
//write new numbers to file
$ft = fopen("newYearPartyTemp.txt","a+");
$lineA = "Adults: ".$numAdults."\r\n";
$lineC = "Children: ".$numChildren."\r\n";
$lineG = "Guests: ".$numGuests."\r\n";
$lineT = "Total: ".$numTotal."\r\n\r\n";
fwrite($ft, $lineA);
fwrite($ft, $lineC);
fwrite($ft, $lineG);
fwrite($ft, $lineT);
$fn = fopen("newYearParty.txt","a+");
for($i=0; $i<5; $i++)
{ $line = fgets($fn);
}
while(!feof($fn))
{ $line = fgets($fn);
fwrite($ft, $line);
}
fclose($fn);
fclose($ft);
unlink("newYearParty.txt"); //delete newYearParty.txt
rename("newYearPartyTemp.txt","newYearParty.txt"); //rename newYearPartyTemp.txt to newYearParty.txt
//end of write new numbers to file
?>
Any ideas on how to fix this up? Thanks a lot in advance.