>>>>> "Marcus" == Marcus <lists@stripped> writes:
Marcus> On 09.07.00 at 15:28 Wesley Darlington wrote:
>> my $search_regex = $dbh->quote($search_string); $search_regex
>> =~ s/\%/\\\%/g; # Escape % signs too $search_regex =~
>> s/^'/'\%/; # Add a percent at the beginning... $search_regex
>> =~ s/'%/\%'/; # ...and at the end my $query = "SELECT Text FROM
>> Table WHERE Text LIKE $search_regex";
Marcus> Thanks for all your replies so far. What I don't
Marcus> understand is why quote() is necessary? Would anybody
Marcus> mind explaining just so I also understand what I'm doing
Marcus> This is what's wrong: When I want to match the 'title'
Marcus> field and I input the exact string in the field
Marcus> (eg. 'Perl'), I get a 100% match using 'LIKE $string', and
Marcus> it works. However, as soon as I input a part string
Marcus> (eg. 'erl') , I get an error. Why does it work with the
Marcus> exact match?
Marcus> I've tried '%$string%' too, as stated in the Mysql
Marcus> manual. No luck. Any ideas what I'm missing here?
Marcus> Marcus Friedlaender
man DBI - look for placeholders and save yourself some of this