Perhaps try getting a simple example up and running and then take it from there.
This uses the test db that came with my download of MySQL. There is a table called foo with two fields id and name.
Note the use of placeholders that other monks have mentioned.
Give this a go and let us know how you get on.#!/usr/bin/perl use strict; use warnings; use DBI(); my $server = 'local'; my %db = ( local => { db => 'test', host => 'localhost', user => '', pwd => '', }, ); my $dbh; $dbh = DBI->connect( "DBI:mysql:database=$db{$server}{db};host=$db{$server}{host}", $db{$server}{user}, $db{$server}{pwd}, {RaiseError => 1} ) or die "couldn't connect"; my @data = <DATA>; chomp @data; my $sth = $dbh->prepare( q{ INSERT INTO foo (id, name) VALUES (?, ?) } ) or err_db(); for (@data){ my ($id, $name) = split /,/; $sth->execute( $id, $name, ) or die "couldn't execute"; } __DATA__ 103,john 104,jack 105,jenny
One more thing - don't panic! :-)
In reply to Re: Strict Ref : ERROR
by wfsp
in thread Strict Ref : ERROR
by swetashah23
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |