writer Posted May 15, 2008 Share Posted May 15, 2008 When trying to use the code below, I'm getting an error. From Googling the error, I can tell that I have to write to a relative path, but I'm not familiar with fwrite() and need some help figuring out where. Error: Warning: fopen(http://www.washingtonpost.com/wp-dyn/rss/print/index.xml1210815958) [function.fopen]: failed to open stream: HTTP wrapper does not support writeable connections in /home/taylorwb/public_html/aheds/WaPoScrape.php on line 7 Warning: fwrite(): supplied argument is not a valid stream resource in /home/taylorwb/public_html/aheds/WaPoScrape.php on line 8 Warning: fclose(): supplied argument is not a valid stream resource in /home/taylorwb/public_html/aheds/WaPoScrape.php on line 9 Code: <?php $path = "http://www.washingtonpost.com/wp-dyn/rss/print/index.xml"; $xml = file_get_contents($path); echo $xml; $name = substr($path, strpos("/", $path), strlen($path)); $file = fopen($name . time(), "w"); fwrite($file, $xml); fclose($file); ?> Link to comment https://forums.phpfreaks.com/topic/105685-error-writing-a-file-locally-using-fwrite/ Share on other sites More sharing options...
DyslexicDog Posted May 15, 2008 Share Posted May 15, 2008 Warning: fopen(http://www.washingtonpost.com/wp-dyn/rss/print/index.xml1210815958) [function.fopen]: failed That error message is telling you everything you need to know. You can't open a file for writing using the HTTP protocol. That's like you trying to open a file on a webserver with notepad directly then attempting to save changes, all over HTTP. HTTP doesn't work that way. Link to comment https://forums.phpfreaks.com/topic/105685-error-writing-a-file-locally-using-fwrite/#findComment-541486 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.