Every now and again, you'll be asked to generate a file—perhaps from a database export, or maybe some system logs. Most of the time, you'll be asked to e-mail that file to some location, but sometimes, you'll be asked to upload it to an FTP folder the client has access to. We're going to take a recipe from a previous chapter (Generating a CSV from a database result from Chapter 6, Working with Databases), and adapt it so that it uploads to an FTP location rather than stream an output.
We're going to be pulling some values from a database. To do that, we'll need a table to pull data from. The following is the schema for that table. Copy the following into your database:
CREATE TABLE `users` ( `user_id` int(11) NOT NULL AUTO_INCREMENT, `user_firstname` varchar(255) NOT NULL, `user_lastname` varchar(255) NOT NULL, `user_email` varchar(255) NOT NULL, PRIMARY KEY (`user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;# MySQL returned...