PDA

View Full Version : Please count my penguins.



techno_race
08-15-2008, 08:07 PM
I wrote a script (with a tutorial) to count my penguins.

//check if the form has been submitted
if(isset($_POST['submit'])){
//try to open the file
if($fp=fopen('penguins.txt','a+')){
flock($fp, LOCK_EX);
//write to the file
$fp3 = $_POST['thename'];
$fp2 = $fp+$fp3;
fwrite($fp2. "n");
flock($fp,LOCK_UN);
fclose($fp);
//inform user that the writing was a success
echo "You have ".$fp2." penguins now.";
}else{
echo "There was an error, could not store the penguin.";
}
}
$fp4=fopen('penguins.txt','a+');
echo "You have ".$fp4." penguins.";

But for some reason, I ALWAYS HAVE 3 PENGUINS. :confused::rolleyes::o:p:(

techno_race
08-15-2008, 08:09 PM
And the script resets itself to RESOURCE ID #2 PENGUINS when I run it.