markrudling Posted April 28, 2011 Share Posted April 28, 2011 Hi guys <?php sleep(00); $handle = fopen("http://www.myurl.com/?bla=bla=bla" , "r"); fclose($handle); ?> How do i prevent this from outputing to a file on my server. I only need the url to be accessed to add a new row of data to my DB. Any Ideas? Regards Mark Quote Link to comment Share on other sites More sharing options...
JKG Posted April 28, 2011 Share Posted April 28, 2011 is the file local? Quote Link to comment Share on other sites More sharing options...
Tonic-_- Posted April 28, 2011 Share Posted April 28, 2011 If you mean you're trying to open a URL to get data from a page and add it to your database I could suggest cURL. I like it more then fopen, etc. Quote Link to comment Share on other sites More sharing options...
PaulRyan Posted April 28, 2011 Share Posted April 28, 2011 You could possibly use header() Send the current page to the URL that adds the record, then use header() again to go back to the file you sent the data from? or possibly to a different file? Regards, PaulRyan. Quote Link to comment Share on other sites More sharing options...
markrudling Posted April 28, 2011 Author Share Posted April 28, 2011 The URL is local to the server. All I need to do is trigger the URL. Everything else is done in the URL that is being triggered. I dont need the output from any of the files. Thanks Mark Quote Link to comment Share on other sites More sharing options...
Tonic-_- Posted April 28, 2011 Share Posted April 28, 2011 Oh, so you just need to execute the page. Do not want output? As i said cURL is useful for this.. But there are much easier ways. Quote Link to comment Share on other sites More sharing options...
markrudling Posted April 28, 2011 Author Share Posted April 28, 2011 The easyer the better Im sure i use to have this working with a simple one or two lines. Regards Mark Quote Link to comment Share on other sites More sharing options...
JKG Posted April 28, 2011 Share Posted April 28, 2011 might be wrong, but can you use exec() for this? or does that output... Quote Link to comment Share on other sites More sharing options...
markrudling Posted April 28, 2011 Author Share Posted April 28, 2011 PS, im happy to have one output file that gets overwriten every time, i just dont want thousands of files on the root of my server. (current setup) Quote Link to comment Share on other sites More sharing options...
markrudling Posted April 29, 2011 Author Share Posted April 29, 2011 Anyone? Quote Link to comment Share on other sites More sharing options...
JKG Posted April 29, 2011 Share Posted April 29, 2011 is this a stupid suggestion: place in an iframe at the bottom of page, with styling to display:none that way all the html would be processed the user would see the page, and the script, would be out of site out of mind... Quote Link to comment Share on other sites More sharing options...
markrudling Posted April 29, 2011 Author Share Posted April 29, 2011 Perhaps I should have mentioned earlyer. The page is not accessed by humans, only by a CRON job that is run every min. The page runs a sql query that captures data from a ever changing text file. Every time the CRON job fires, the page is accessed and the DB is populated with a new row. However, as it stands, a file is also created on the root. I have 6 files that run every min, so 8640 files are being written to my root every day.. I need the files to either be overwriten or not writen at all. Thanks Mark Quote Link to comment Share on other sites More sharing options...
JKG Posted April 29, 2011 Share Posted April 29, 2011 what file does this output? fopen wouldnt output a file to say a file has been opened... Quote Link to comment Share on other sites More sharing options...
markrudling Posted April 29, 2011 Author Share Posted April 29, 2011 There are 6 files, each with a acending 10second delay, named import00.php, import10.php etc etc in the root of my hosting directory, files with the same name are created with an extra .1 .2 etc added as the suffex. If i run the url that is being called by the import00.php file, no output file is created. It is being caused when the cron job runs the import00.php file. mmmm Now looking at it, im not sure if the output file is being created by the cron job or the php file... Quote Link to comment Share on other sites More sharing options...
markrudling Posted April 29, 2011 Author Share Posted April 29, 2011 OK OK, I am the weakest link... I was using webget in my cron job insted of curl.... Updated cron jobs, no more files.. Sorry to waist your time and thank you everyone for the help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.