function doesnt write to the file
Posted: Fri Feb 02, 2007 12:50 am
Hi,
this is a function that is avaialable on php.net. Im using this function for writing the content into file.
I've created a file called $filename in the directory where this script runs. It returns the error cannot change the mode file file_content.xml. I gave all the permissons possible on the file. But it still doesnt write.. What could be the problem
Thank You
this is a function that is avaialable on php.net. Im using this function for writing the content into file.
Code: Select all
function file_write($filename, &$content) {
if (!is_writable($filename)) {
if (!chmod($filename, 0666)) {
echo "Cannot change the mode of file ($filename)";
exit;
};
}
if (!$fp = @fopen($filename, "w")) {
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;
}
}Thank You