Hi,
I am trying to insert a lots file paths into an SQLite table and am
having trouble with filenames with apostrophes in.
Below is the snippet I have been using. I have experimented with
sprintf, qq and a combination of both but can't get a quoting system
that will get DBI to accept paths like q(/path/to/Camellia japonica
'Mercury'2.tif).
I don't want to transform the path. I want to maintain the true path
without having to do substitiutions everytime the data gets read from
or inserted into the table. It would be a maintenance headache
otherwise.
Is there a technique for this anyone or any advice anyone can offer
(apart from shooting the users how uploaded the files in the first
place).
TIA,
Dp.
sub Check_if_exists {
my $name = shift;
my $str = qq($name);
my $statement = sprintf("SELECT id FROM files where
path='%s'",$str);
# my $statement = qq("SELECT id FROM files where path="$str"");
my $rows = $dbh->selectrow_array($statement) or die "Can't
selectrow_array statement=$statement: ",$DBI::errstr,"\n";
return $rows;
}
DBD::SQLite::db selectrow_array failed: near "Mercury": syntax
error(1) at dbdimp.c line 271 at myfile.pm line 158.
Can't selectrow_array statement=SELECT id FROM images where
tiffpath='/data/finished/GB 10484/Camellia japonica
'Mercury'2.NEF.tif': near "Mercury": syntax error(1) at dbdimp.c line
271
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/