in reply to Re^3: DBI search for forward slash
in thread DBI search for forward slash

Sorry for delay. THis is my code
$dbh->do("CREATE TABLE IF NOT EXISTS `test` ( `string` VARCHAR(256))" +); my $string = '/a/b/c/d'; my $I = qq{ INSERT INTO `test` (`string`) VALUES (?) }; my $sI = $dbh->prepare($I); $sI->execute($string); my $R1 = qq{ SELECT * FROM `test`}; my $sR1 = $dbh->prepare($R1); my $row1 = $sR1->execute(); say "total1: $row1"; while( my $L1 = $sR1->fetchrow_hashref ) { say "$L1->{'string'}"; } my $R2 = qq{ SELECT * FROM `test` WHERE `string`=?}; my $sR2 = $dbh->prepare($R2); my $row2 = $sR2->execute(); say "total2: $row2"; while( my $L2 = $sR2->fetchrow_hashref ) { say "$L2->{'string'}"; }
produce:
total1: 1 /a/b/c/d total2: 0E0

Replies are listed 'Best First'.
Re^5: DBI search for forward slash
by haukex (Bishop) on Nov 08, 2020 at 08:34 UTC
    my $R2 = qq{ SELECT * FROM `test` WHERE `string`=?}; my $sR2 = $dbh->prepare($R2); my $row2 = $sR2->execute();

    You forgot to pass $string to ->execute as a value for the placeholder. $sR2->execute($string); works as expected.

      yes i've spot this typo. It is working like that now But really, I'm trying to understand when is my problem now. my old code, with table, produced via phpMyAdmin not working. yes, i've check and it is clear for me now - my foreigner table has spaces in the string which was not easy to spot, but spaces are still counting in exact match.... Oh again silly error.... Feel really sorry for this realyl stupid question
        Oh again silly error.... Feel really sorry for this realyl stupid question

        Don't worry, we all have moments like that! I hope you now see the value of a representative SSCCE :-)