At 21:52, 19990727, Rich Bowen wrote:
>Richard Reina wrote:
>> Can someone send me a very simple perl script that connects to a mysql
>> database and modifies a table.
>my $dbh = DBI->connect('DBI:mysql:database', 'username',
die "connect failed: $DBI::errstr" unless $dbh;
>my $sth = $dbh->prepare("insert into tablename
die "prepare failed:", $dbh->errstr unless $sth;
$sth->execute or die "execute failed:", $sth->errstr;
>That's about as simple as it gets.
That was too simple. Also, if you're storing character data
(CHAR, VARCHAR, BLOB, etc.), don't forget to quote your values
before you insert them! Or, use the placeholder feature of DBI
which will quote them for you.