joemidnite has asked for the wisdom of the Perl Monks concerning the following question:
I have also used as a variation:use DBI; use strict; my $dbh = DBI->connect('DBI:mysql:gailbord_teachcoll', 'gailbord_admin +', 'thotwp2') || die "Could not connect to database: $DBI::errstr"; my $affInfo = $dbh->do ('INSERT into teach_info (pickup, pmonth, pday, + pyear) values ($pickup, $pmonth, $pday, $pyear)'); print "$affInfo Row Added\n"; $dbh->disconnect();
I have tried variation after variation from help from the web and books. I am sure the code above worked a few years ago, and after trying everything else, I believe it should still work, I just need some advice. I understand what it is doing, I use php to do the same, but want work with PERL. The connection works, I proved that by mistyping the password, and got an error, and I used my $info = $dbh->{'mysql_hostinfo'}; and got back: Localhost via UNIX socket.my $dbh = DBI->connect('DBI:mysql:gailbord_teachcoll', 'gailbord_admin +', 'thotwp2') or die "Unable to connect: $DBI::errstr\n"; my $sql = "INSERT into teach_info (pickup, pmonth, pday, pyear) values + ($pickup, $pmonth, $pday, $pyear)"; my $sth = $dbh->prepare($sql); $sth->execute();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Problem with DBI and MySQL
by ikegami (Patriarch) on Aug 22, 2010 at 22:44 UTC | |
|
Re: Problem with DBI and MySQL
by shmem (Chancellor) on Aug 23, 2010 at 00:09 UTC | |
by ait (Hermit) on Aug 23, 2010 at 01:29 UTC | |
by ruzam (Curate) on Aug 23, 2010 at 00:41 UTC | |
|
Re: Problem with DBI and MySQL
by FloydATC (Deacon) on Aug 23, 2010 at 06:18 UTC | |
by roboticus (Chancellor) on Aug 23, 2010 at 11:12 UTC | |
by FloydATC (Deacon) on Aug 25, 2010 at 15:52 UTC | |
|
Re: Problem with DBI and MySQL
by CountZero (Bishop) on Aug 23, 2010 at 17:53 UTC |