PHP overwrite file

Soldato
Joined
1 Feb 2006
Posts
8,188
Hi guys,

I have written a piece of code which will create an RSS file and export data into the file. I will be running this file on the server at set intervals such as every 15 minutes so therefore I need to create a file, then 15mins later overwrite the file with a new updated version from the database.

The following code is what I have so far:

Code:
$handle = fopen("$full_path", "x+");
			
$xml = "stuff goes here from database";
			
fwrite($handle, $xml);
fclose($handle);

How can I modify this code to ensure that if a file already exists on my webserver it will automatically be overwritten with the new file produced by this code?

Any help would be appreciated. Cheers
 
hi guys, thanks a lot for the info. Using the 'w' mode worked a treat. Instead of using a cron tab to run every 15 mins is it possible to only run as soon as an update is executed on the database? Kind of like a trigger idea? Someone suggested the other day to me that MySQL doesnt support triggers but maybe there is another workout for checking the database.

Thanks again
 
Just following on from this guys, I have created links within my RSS feeds to go directly to pages in my site. As I am testing this on a localhost address, none of the functionality is enabled. I can view the page but no links work. Are there any workarounds for this? Or does anyone know will a newsreader application work with localhost addresses? Thanks
 
sorry im a mac newb and i dont follow at all! have you any links to instructions? sorry for being a pain

edit: i am using mamp as my local testing platform if that means anything
 
Last edited:
Back
Top Bottom