I've build a Flash Viewable XML blogging system. I am in the process of creating the back end part of the project (adding, editing, deleting).
The code below should just open my blog.xml file and write to it. Should be simple...and I thought I had this code working before. The file extension is xml, but even changing that to txt doesnt seem to help. I am getting an error in my browser that says "No input file specified". Anyways, This is probably one of those "doh" moments.
<?php
//create data for file
$xml = "<?xml version=\"1.0\"?>
<blog>
<entry title=\"Testing the Blog\" date=\"Sept 13\" content=\"Test content\" />
</blog>";
//file
$filename = 'blog.xml';
// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
if (fwrite($handle, $xml) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success.";
fclose($handle);
}else{
echo "The file $filename is not writable";
}
?>