I wrote this script to back up a table in my mySQL database. It also names the file with the exact time from the server that the backup occurred. It might not be the best approach, but it worked for me as the only user. Just adjust the column names to fit your needs.
When I posted a similar question, I also received information about a mysql command named "mysqldump" http://www.mysql.com/doc/en/mysqldump.html. My hosting company would not let me use this command, so I wrote the following script: sub backup { my $dbh = shift; my ($sth, $stmt, $count, $row); my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); my $time = localtime(time); my $currentyear = $year + 1900; my $currentmonth = $mon + 1; my $currentday = $mday; my $currenthour = $hour; my $currentmin = $min; my $currentsec = $sec; my $filename = "$currentyear$currentmonth$currentday$currenthour$currentmin$currentsec.txt" ; print "Content-type:text/html\n\n"; print<<ENTRYFORM; <html> <head> <title>Survey Backup!</title> <style type="text/css"> <!-- .main { font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #000000;} .mainsmall { font-family: Arial, Helvetica, sans-serif; font-size: 10px; color: #000000;} .head { font-family: Arial, Helvetica, sans-serif; font-size: 14px; font-weight: bold; color: #FFFFFF;} --> </style> </head> <body bgcolor="#FFFFFF" leftmargin="0" topmargin="10" marginwidth="0" marginheight="10"> ENTRYFORM print "$time<br>"; print "$sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst<br>"; print "$filename"; open(OUTFILE,">$filename") or dieerror("Can't open $filename: $!"); $stmt = qq { select * from Survey }; $sth = $dbh->prepare ($stmt); $sth->execute (); while (my $row = $sth->fetchrow_hashref()) { print OUTFILE "$row->{participantId}|$row->{participantDate}|$row->{participantFirstName}| $row->{participantLastName}|$row->{participantPhone}|$row->{participantPhone Extension}|$row->{participantState}|$row->{participantDivision}|$row->{parti cipantEmail}\n"; } $sth->finish(); close(OUTFILE); print<<ENTRYFORM2 </body> </html> ENTRYFORM2 } Hope this helps! Andrew -----Original Message----- From: T. Murlidharan Nair [mailto:[EMAIL PROTECTED] Sent: Wednesday, March 26, 2003 11:49 AM To: [EMAIL PROTECTED] Subject: downloading data as text file Hi!! I need to provide the users that access my database a way to download data as a text file. The data is stored in a mysql database, has anyone done this, if so I would really appreciate their help. Thanks and Cheers always!! Murli -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]