I need to write a cron job that retrieves a zipped XML file via FTP, unzips it, and then imports the XML into MySQL. I haven't done any of these three specific functions yet. Before I tear my hair out on each of these functions, can anyone point me to a simple example of any or all three?
Download a file : use the 'wget' program if its available on your system. Since you mentioned cron, I assume you are working on linux/unix or similar. If wget is not available, try links/lynx. If those aren't available either, then you can use any of the HTTP classes, such as HTTP_Client (from pear) or my favorite snoopy.sf.net. If your PHP install is bundled with curl, you can also use the curl functions (http://www.php.net/curl)
Unzip a file : http://www.php.net/manual/en/ref.zip.php (example is right there in the manual entry)
XML: If you are on PHP5, then use simplexml, otherwise, use the regular xml functions. Plenty of examples and tutorials on the internet. Google is your friend.
Import into MySQL : just use the mysql command line client if its available to you. mysql -u username -ppassword databasename < file.sql
If it is not, use the regular mysql functions to submit queries (mysql_connect, mysql_select_db, and mysql_query).
Regards, Burhan
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php