Script needed for database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
pyrotech
Forum Newbie
Posts: 1
Joined: Tue Nov 09, 2010 8:59 am

Script needed for database

Post by pyrotech »

Is there a script out there that would put images from an online source into a data base and update it regular
Need something already made that i can adapt perhaps.
Needs to get latest image every 6 hours and put it in database, 100s of images
For instance a weather chart showing rainfall in 3 hrs time, 6hrs time ect
Then Surface pressure for same time scales
and more and more so its alot of work
Then a file to allow users to retreive data and see relevant chart.

Its for a free website that warns users about severe weather and flood problems
Any help or direction pointing really appreciated.

Like i said may be a program out there that can be adapted.
User avatar
mecha_godzilla
Forum Contributor
Posts: 375
Joined: Wed Apr 14, 2010 4:45 pm
Location: UK

Re: Script needed for database

Post by mecha_godzilla »

Hi,

I'll try to offer some "direction pointing"...

1. If you need something to happen at regular intervals, you need to look at using cron (assuming you're on a Linux platform) or whatever the equivalent is for Windows set-ups. What you just need cron to do is to run your PHP script. If your server account is very basic then you might not have access to cron; most shared hosting accounts do normally have some (limited) access but these things are much easy if you have root access to the server.

2. The way to automatically retrieve an image (using the PHP script called in your cron profile) is to use something like cURL. This libary can act - in a very rough sense - as something akin to an automated web browser. cURL can be used for things like automated posting to blogs/Twitter but can also be used to retrieve web content as well (for example, to aggregate news feeds). As mentioned above, if your server account is basic you'll need to check whether the cURL libraries are available or not.

I'm not sure if there are any open source applications out there that will do what you want but PHP and all the different 3rd party libraries should certainly give you enough tools to do this. I have a feeling that the best way forward might be to find a script that handles the image retrieval first, then adapt this to store the results in your DB. You'll probably want to write your own front-end to access the images as it might be quicker than trying to adapt an off-the-shelf application.

HTH,

Mecha Godzilla
Post Reply