Thanks so much. I got some help offline that did the trick. The suggestion that worked was to do the following:
my $filename = "out.txt"; open(OUTFILE,">$filename"); $stmt = qq { select * from 2002brochurecontest }; $sth = $dbh->prepare ($stmt); $sth->execute (); $count = 0; while (my $row = $sth->fetchrow_hashref()) { print OUTFILE "$row->{id}|$row->{t}|$row->{f_name}|$row->{l_name}|$row->{w_phone}|$row->{w _phone_ext}|$row->{division}|$row->{email}|$row ->{eclub}|$row->{country}|$row->{brochure}|$row->{purchase}\n"; } $sth->finish(); close(OUTFILE); Thanks, Andrew -----Original Message----- From: LRMK [mailto:[EMAIL PROTECTED]] Sent: Monday, January 06, 2003 2:16 PM To: Hughes, Andrew; [EMAIL PROTECTED] Subject: Re: how to print mysql table to text file backup with perl where do you want to save your file on your PC or on the server Sign L Rakhitha Malinda Karunarathne Web :- rakhitha.cjb.net Email :[EMAIL PROTECTED] Rakhitha Malinda Karunarathne. ----- Original Message ----- From: "Hughes, Andrew" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, January 07, 2003 12:58 AM Subject: how to print mysql table to text file backup with perl > I have a mysql table with about 3000 rows of data on which that I need to > perform a daily backup. Because I am on a shared hosting account I do not > have administrative rights to the database. To back it up currently I have > a script that prints each line of data to the browser delimited with pipes > using this code: > > > $stmt = qq { select * from 2002brochurecontest }; > $sth = $dbh->prepare ($stmt); > $sth->execute (); > $count = 0; > while (my $row = $sth->fetchrow_hashref()) > { > print > "$row->{id}|$row->{t}|$row->{f_name}|$row->{l_name}|$row->{w_phone}|$row->{w > _phone_ext}|$row->{division}|$row->{email}|$row > ->{eclub}|$row->{country}|$row->{brochure}|$row->{purchase}", > br(); > } > $sth->finish(); > > I take the output and print it to my browser. Then I cut and paste it into > a text file. To avoid this extra step and to learn something new, I would > like to print the data to a text file. Each day I would just overwrite the > same text file with the data, so I would not have to create a new file every > time the script runs. Can anyone point me in the right direction? > > Thanks, > Andrew > > -- > 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]