Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to write to an XML file in a WordPress Plugin. I'm on my local machine, a Mac running MAMP. I have PHP 5.2.13 My code is:

$file_handle = fopen('markers.xml', 'w');
$stringdata = "Test Info";
fwrite($file_handle, $stringdata);
fclose($file_handle);

I get the following error:

Warning: fopen(markers.xml) [function.fopen]: failed to open stream: Permission denied in /Users/my_name/Sites/my_site/wp-content/plugins/my_plugin_folder/my_plugin_main_file.php on line 73

Warning: fwrite(): supplied argument is not a valid stream resource in /Users/my_name/Sites/my_site/wp-content/plugins/my_plugin_folder/my_plugin_main_file.php on line 75

Warning: fclose(): supplied argument is not a valid stream resource in /Users/my_name/Sites/my_site/wp-content/plugins/my_plugin_folder/my_plugin_main_file.php on line 76

markers.xml has permissions set to 777.

Any suggestions on how to solve this problem?

Thank you.

share|improve this question
add comment

1 Answer 1

up vote 0 down vote accepted

Check folder permissions too.

Also See this post http://www.php.net/manual/en/function.fopen.php#105465 - suggests he had to change to absolute from relative to get around error message.

Set of debug suggestions here: http://www.wrensoft.com/forum/showthread.php?t=786

1) folder permissions 2) upper/lowercase 3) abs/relative path and finally it turned out to be an extra space somewhere,

share|improve this answer
    
Thank you for the help. I changed the file permissions and switched it to an absolute path. –  Laxmidi Oct 6 '11 at 19:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.