>>>>> "Randy" == Randy Peterman <[EMAIL PROTECTED]> writes:

Randy> Is my problem with MS Access, or is there formatting to be done to the 
Randy> fields.  I am using CGI.pm as well to process all the returned values, 
Randy> does this cause any undesired changes to the values?  Could the comma 
Randy> between the author's last and first name be causing the error?  My 
Randy> insert statement looks approximately like this:

Randy> $SQL = "INSERT INTO books VALUES ($TITLE, $AUTHOR, etc)";
Randy> $STH = $DBH->do($SQL) or die "$!";

Please look at the "quote" method in "perldoc DBI".  Also, look at
using placeholders.

You could do:

| my $title_q = $dbh->quote($title);
| my $author_q = $dbh->quote($author);
| 
| my $sql = "INSERT INTO books VALUES ( $title_q, $author_q ...);
| $dbh->do($sql)
|   or die "error inserting.  SQL=\"$sql\", Error=$DBI::errstr";

Or you could do:

| my @vals = ( $title, $author, $publisher, ...)
| my $placeholders = join ', ', ('?') x @vals;
|
| my $sql = "INSERT INTO books VALUES ($placeholders)";
| $dbh->do($sql, {}, @vals)
|   or die "error inserting.  SQL=\"$sql\", args=[@args], Error=$DBI::errstr";

Again, much more information is available in "perldoc DBI".  

Note that $! doesn't really have anything to do with DBI; use its
errstr instead.

t.

Reply via email to