|
hi,
I am trying to write data to .csv file that already exists with
777 permissions, but still getting:
[ Warning: chmod(): Operation not permitted in /usr/local/www/vhosts/shanzoo.com/htdocs/shortapp.php on line 22
Cannot change the mode of file (visit/shortapp.csv) ]
Here is the code i m using:
<?php
if (isset($submitted))
{
$datetime = date("D dS M,Y h:i a");
$msg = "$datetime
How did you hear about us: $hear
First name: $b_firstname
Last name: $b_lastname
";
mail("apply@shanzoo.com","Short Application",$msg,"From: $b_email");
///New Changes for writing
$filename = 'visit/shortapp.csv';
$content = "\"$datetime\",\"$hear\",\"$b_firstname\",\"$b_las tname\"\n";
if (!is_writable('$filename')) {
if (!chmod($filename, 0666)) {
echo "Cannot change the mode of file ($filename)";
exit;
};
}
if (!$fp = @fopen($filename, "a")) {
echo "Cannot open file ($filename)";
exit;
}
if (fwrite($fp, $content) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
if (!fclose($fp)) {
echo "Cannot close file ($filename)";
exit;
}
/// ----------------------
unset($submitted);
header("location: thankyou.php");
exit;
}
else
{
header("location: error.php");
exit;
}
?>
I am really stuck, Please suggest what am i doing wrong?
thanx in advance
FriendLee
|