Placeholder question

Placeholder question

am 02.10.2003 08:05:03 von Mike Garner

I learned about placeholders/bind variables from this list and have been
using them relatively successfully for a little bit now. However, the
following query (a very simple one) doesn't work.
my $key='1';
my $name='mike';
$statement=<<"end";
update mentors set firstname=? where id=?;
end
$query=$dbh->prepare($statement);
$query->execute($name,$key) or die "Can't execute query: " . $dbh->errstr
.."\n";

#$query="update mentors set firstname='mike' where id=$key";
#$sth=$dbh->prepare($query);
#$sth->execute();

The commented query without placeholders works fine. When I run it using
the query that contains place holders I get this error:
DBD::mysql::st execute failed: You have an error in your SQL syntax near ';
' at line 1 at test.pl line 10.
DBD::mysql::st execute failed: You have an error in your SQL syntax near ';
' at line 1 at test.pl line 10.

Line 10 is the $query->execute($name,$key); line. Any ideas?

Thanks,
Mike


------------------------------------------------------------ --
Mike Garner
Western State College
Email: mgarner@western.edu
Voice: 970-943-3123
Fax: 970-943-7069


--
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe: http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules@m .gmane.org