Maybe I'm missing something simple (usually the case). I've searched through the forums and found similar problems, but not quite the same as mine.
I am trying to write to a file (datafile.xml) using PHP in myfile.php.
Here is my code:
>$filetoopen=$_SERVER["DOCUMENT_ROOT"]."/travel/data/datafile.xml";
if ($fp = fopen($filetoopen,"r+") !== false) {
$newcode.='<p>Blah blah blah. Test text here.</p>';
fseek ($fp,-16,SEEK_END); //go to the end of the file, and back up 17 bits
if (fwrite($fp,$newcode,700)!==false)
echo 'Success';
else
echo 'Error';
fclose($fp);
}
fopen seems to work fine. The errors I'm getting are:
Warning: fseek(): supplied argument is not a valid stream resource in /home/myusername/public_html/travel/myfile.php on line 43
Warning: fwrite(): supplied argument is not a valid stream resource in /home/myusername/public_html/travel/for_us/myfile.php on line 46
Warning: fclose(): supplied argument is not a valid stream resource in /home/myusername/public_html/travel/for_us/myfile.php on line 54
I have even tried is_readable and is_writeable using $filetoopen and they are both true. I have tried other things such as fgets and get the same error. Permissions on datafile.xml are 666, and the directory 'data' is set to 777. I'm not sure what else to try. Thanks in advance for any help you can give. I'm so frustrated with this.
~LPet