I would connect using:
my $dbh=DBI->connect($SID, $user, $pass, {RaiseError=>1});
and avoid typing all the '.. or die' clauses. Because if you get an error, it gives
you a place to start looking and if you need to, you can just add a debug 'print' statement
before the failing statement on the next go round.
That being said, there should be no reason why your statement can not
find fields with spaces in them. My guess is that either the prepare
is failing or your bind variable has characters besides spaces
that you're not expecting. Maybe you need to convert
the bind_variable to hex and print that out to see if there
are any weird characters like linefeeds sneaking in. One guy I worked
with swore up and down that "placeholders don't work" and
he avoided using them, and we found that the input was
getting a carriage return character. (He also complained that
"arrays don't work" for similar reasons, but that's another
story - he would always avoid using things instead of debugging
and figuring out what's wrong).
Also, I hope that you don't really have
html breaks in the middle of your sql statement because
that definitely would cause the prepare to fail.