FWrite is failing randomly. It works beautifully sometimes, then fails on others, even when the same data is passed to the function. It will write tiny files without problem.
What am I doing wrong? Can anyone help?
Here is my code
// write XML files function
function writeXML($filename, $content) {
$filepath = $filename . ".xml";
$file = fopen($filepath, w);
if ($file) {
$written = fwrite($file, $content);
if ($written) {
$saved = fclose($file);
if ($saved) {
return true;
} else {
//echo "failed to save file";
}
} else { //echo "failed to write file";
}
} else {
//echo "failed to open file";
}
return false;
}
cheers
Rachel