Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^4: DBI search for forward slash

by luxs (Beadle)
on Nov 08, 2020 at 08:31 UTC ( #11123493=note: print w/replies, xml ) Need Help??


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 :-)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://11123493]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2021-05-13 03:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Perl 7 will be out ...





    Results (134 votes). Check out past polls.

    Notices?