Greg D . wrote at Thu, 30 May 2002 23:52:35 +0200:

Like Beau E. Cox, I don't know, too, why it doesn't run.
But when it will run,
you should take off the preparation of the sql command
out of the while loop.

That's why the command is created for.
So you can speed up and more important improve the readability.

> Hello,
> 
> I am trying to open up a text file where each field is parsed by |. the problem is 
>that its only
> reading the first line in the text file. I want it to loop throughtout the the 
>textfile and insert
> in a DB.
> 
> ANyhelp is appreciated...thnx
> 
> the code is:
> 
> open(GD, "$ktjpath/$ktjlist") || &death("Can't open $ktjlist: um121"); while (<GD>){
>         ($id, $number2, $number3, $fname, $email, $cemail, $passwd, $code,
> $stuff, $stuff2) = split /\|/;
>         
>  $sql_statement = "INSERT INTO ktj (number2, number3, fname, email, cemail,
> passwd, code, stuff, stuff2) values (?, ?, ?, ?, ?, ?, ?, ?, ?)";
>         $sth = $dbh->prepare($sql_statement) || die "Error1 preparing insert
> statement:\n" . $dbh->errstr;
>         $sth->execute($number2, $number3, $fname, $email, $cemail, $passwd,
> $code, $stuff, $stuff2) || die "Error2 executing bind\n" . $sth->errstr;
> }
> close GD;
 
In hope, that anybody can really solve the problem.

Cheerio,
Janek

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to