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();
In reply to Problem with DBI and MySQL by joemidnite
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |