I was trying to debug a 70 line SQL statement and it kept insisting that I was trying to call the statement with one bind variable when none were needed. I called over smylers and he was mystified, too. We tried many different things, but clearly there was a bind variable that wasn't being recognized. Pasting the SQL directly into MySQL seemed fine (though obviously without the bind variable).
Then smylers pointed out in my liberally commented SQL that I had single quote marks (') in said comments. I removed all of those quote marks and the SQL ran just fine. Here's a small program which reproduces the error:
#!/usr/bin/perl use strict; use warnings; use DBI; my $dsn = "DBI:mysql:database=mydatabase;host=localhost"; my $dbh = DBI->connect( $dsn, qw/user pass/, { RaiseError => 1 } ) or die $DBI::errstr; $dbh->do('DROP TABLE IF EXISTS buggy'); $dbh->do('CREATE TABLE buggy ( id int(3) )'); $dbh->do('INSERT INTO buggy (id) VALUES (1)'); $dbh->selectrow_arrayref(<<'END', {}, 1); SELECT id FROM buggy -- it's a bug! WHERE id = ? END