in reply to Problem with DBI and MySQL
ikegami is right, checking for errors helps. Shortcut:
In your statement
$dbh->do ('INSERT into teach_info (pickup, pmonth, pday, pyear)
the tokens pickup, pmonth, pday, pyear are not symbols at the database level and thus have to be quoted. Use placeholders.
If the values you are inserting are in the column order, you dont need the column enumeration at all - you can just do
But! Again, use placeholders. Remember Bobby Tables:my $sql = "INSERT into teach_info values ($pickup,$pmonth, $pday, $pye +ar)";
update:use DBI; use strict; my $dbh = DBI->connect( 'DBI:mysql:gailbord_teachcoll', 'gailbord_admin', 'thotwp2', { RaiseError => 1 } ); my $sth = $dbh->prepare("INSERT into teach_info values(?,?,?,?)"); $sth->execute($pickup, $pmonth, $pday, $pyear);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Problem with DBI and MySQL
by ait (Hermit) on Aug 23, 2010 at 01:29 UTC | |
|
Re^2: Problem with DBI and MySQL
by ruzam (Curate) on Aug 23, 2010 at 00:41 UTC |