Saving data to a txt from flash

ok maybe this was asked before

but i have an array of variables i want to save to a txt

heres the php code


<?php
$petdata = $_POST['petpost'];
$userid = ("count.txt");
$numid = file($userid);
$numid[0] ++;
$fp = fopen($userid , "w");
fputs($fp , "$numid[0]");
$ourFileName = "pet".$numid.".txt";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fputs($ourFileHandle , "petcode=".$petdata);
echo "pet ID # $numid[0] was created, please remember this for later or write it down someplace <BR><BR> <a href='http://gaiahost.freeweb7.com/pets/pet.php?petid=".$numid."' target='_blank'>Click here for your pet page</a>";
fclose($ourFileHandle);
fclose($fp);
?>

and heres the flash code


on(press) {
petpost= _root.eyecolor,_root.skincolor,_root.hairstyle;
getUrl("petcreation.php", 0, "POST");
}

i’m sure its an easy one to figure out for expert coders @_@

and i was sure i didn’t mess up anywhere

the php writes a file called petarray.txt when its supposed to write something like pet1.txt pet2.txt etc etc

and inside the file it has nothing after the “petcode=”

i’m not sure where i went wrong, could somebody help please?

it would be much appreciated