i want to write data accepted in a form to a text file. this is the code i am using.

$file=fopen("data.txt","a+");
fwrite($file," whatever i want written");
fclose($file);

but nothing is being written to the file.
the text files are in the same place as the php pages.
does anyone know why its not working?

heres the whole thing if u need it.

<?php

$val1= $_POST["val1"];
$val2=$_POST["val2"];

$file=fopen("idata.txt","a+");
fwrite($file,"whatever i want it to write ");
fclose($file);


switch($val1)
{
case 1:

$file=fopen("data.txt","a+");
fwrite($file,"whatever i want it to write");
fclose($file);
break;

case 2:

$file=fopen("data.txt","a+");
fwrite($file,"whatever i want it to write");
fclose($file);
break;

.
.
.


default:

$file=fopen("data.txt","a+");
fwrite($file,"whatever..");
fclose($file);
break;

}



?>

thanks

check the file is writeable to the user php is running as, CHMOD,

no other thoughts