CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Intermediate:
transfering text files to mysql...



Nov 17, 2001, 11:45 AM

Post #1 of 1 (490 views)
transfering text files to mysql... Can't Post

I am writing a little script to change my flat file databases to mysql, I have a seperate file for each member so I needed it to get all files in the folder and open each one individually and then print, but it seems not to work right now. I have right now:


use CGI qw(:standard);
print "Content-type: text/html\n\n";
require "shopconfig.cgi";

my @count = ();
opendir (DR,"$datapath/members/");
@count = grep { /\..*/ } readdir(DR);
closedir (DR);

foreach $line (sort @count) {

open(LIST, "<$datapath/members/$line");
while(<LIST>) {
my ($Username, $Password, $lname, $fname, $country, $email, $add1, $add2, $city, $state, $zip, $phone) = split/\|/;

use DBI();

# Connect to the database.
my $dbh = DBI->connect("DBI:mysql:database=crashint_test;host=localhost",
"crashint", "PASSWORD",
{'RaiseError' => 1});

# Same thing, but using placeholders
$dbh->do("INSERT INTO foo VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", undef, "$Username", "$Password", "$fname", "$lname", "$country", "$email", "$add1", "$add2", "$city", "$state", "$zip", "$phone");

# Disconnect from the database.




I have printed $line seperately and the files are shown perfectly.

I can get it to work if I do each file seperately, but I need them all done at once.

(This post was edited by crashinto on Nov 17, 2001, 10:47 AM)


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives