Jump to content

madwoman

New Members
  • Posts

    2
  • Joined

  • Last visited

madwoman's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi Thanks for the suggestion, I agree about using a limited number of attempts - am I right in assuming that I need to plug this bit of code in after line 16 of my initial code? Cheers
  2. Hi I am using the following to connect to an external ftp site to collect a txt file which then gets imported into a mysql table. The connection seems a little hit and miss and I want to set up a loop through until the action is successful - can anyone advise how I would add this to my existing script - I have tried a couple of options without success. The existing code is as follows: <?php $today=(gmdate("dmyGi") . ""); // define some variables $local_file = 'IncomingFiles-' . $today . '.txt'; $server_file = 'files.txt'; // set up basic connection $ftp_server="xxx.ftpserver.xxx"; $conn_id = ftp_connect($ftp_server); // login with username and password $ftp_user_name="1234567"; $ftp_user_pass="1234567"; $login_result = ftp_login($conn_id, $ftp_user_name, $ftp_user_pass); // try to download $server_file and save to $local_file if (ftp_get($conn_id, $local_file, $server_file, FTP_ASCII)) { echo "successfully written to filesincoming\n"; } else { echo "there was a problem connecting to the server for the collection of filesincoming"; exit; } I think the issue may be one of the connection timing out so I am not sure whether setting a longish timeout would be a better option but I though that using a loop would allow me to rely more on the script actually completing when I run it as a CRON job eventually. At the moment the run fails to connect about once in every 3 attempts. Any advice would be appreciated.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.