Freelancers Network
 
skill list top cap
Homepage
Join the Freelancer's Network
Update your details
Find a freelancer
Post a project
Find a project
Projects Archive
Post a job
Find a job
Jobs Archive
See Dan's Pages
See Andy's Pages
Link to this site
Resources
Join/Leave Forum
Forum Messages
+Additions+ Adverts
Advertising
Contact Us
Subscribe to our newsletter - enter your email address and hit return
Freelancers.net is owned and operated by Andy Stowell and Dan Winchester
skill list end cap
guru web hostcom

Find me again on Freelancers.net

RE: FN-FORUM: Suggestions please charset="Windows-1250"

date posted 30th January 2006 11:17

[EMAIL REMOVED] wrote:
> I am after a job where there will be csv files on a ftp server that
> will need uploading to a database once a day and I am trying to work
> out the best way to do it. I gather you need "allow_url_fopen = On"
> set in php.ini to be able to use the ftpwrapper. Is it likely to be
> set to on? It should be in php as far as I know unless they change
> their mind. I was wondering about setting up a cron job to do it. Has
> anyone done anything similar as I am looking for pointers in the
> right direction?

This doesn't seem to be a web-based task, so PHP would be a slightly
strange choice of technology. I know that it's possible to write command

line programs in PHP, but you very rarely hear of it being done.

Personally I'd write a Perl program that connects to the FTP server,
downloads the files and inserts the data into the database. I'd then set

up a cronjob that executed that program every day.

Of course, it doesn't have to be Perl. Any programming language would be

suitable as long as it has support for accessing FTP servers and
databases. You could even do it in a Unix shell script as long as you
don't mind using external programs for the FTP and database bits.

Dave...


Dave, I use the CLI version of PHP for every cronjob driven programme
that I create. I gave up using Perl years ago as I couldn't see the
sense in using 2 programming languages when one would do.

Pamela, I would use something like:

fopen(file on local or remote server)
$var = fread(file handle, filesize)
fclose

foreach $var as $line
($values) = split($line, delimter)
insert into table (field) values($values)

If you put !#/path to php in the top of your PHP file you can run the
file from your cron thus:

./name of php file

You can also use $ARGV[0], $ARGV[1] etc. to pass values in on the
command line

Ian


--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.375 / Virus Database: 267.14.23/243 - Release Date:
27/01/2006




Messages by Day
January 31st 2006
January 30th 2006
January 29th 2006
January 28th 2006
January 27th 2006
January 26th 2006
January 25th 2006
January 24th 2006
January 23rd 2006
January 22nd 2006
January 21st 2006
January 20th 2006
January 19th 2006
January 18th 2006
January 17th 2006
January 16th 2006
January 15th 2006
January 14th 2006
January 13th 2006
January 12th 2006
January 11th 2006
January 10th 2006
January 9th 2006
January 8th 2006
January 7th 2006
January 6th 2006
January 5th 2006
January 4th 2006
January 3rd 2006
January 2nd 2006
January 1st 2006


Messages by Month
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
March 2006
January 2006


Messages by Year
2008
2007
2006
2005
2004
2003
2002
2001
2000