Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6933877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:53:20+00:00 2026-05-27T11:53:20+00:00

I think this question is been asked for php and now I am asking

  • 0

I think this question is been asked for php and now I am asking it for perl. I have 2 arrays. I am using it to query my database. Now it happens that the terms are not just a word and so it may have spaces in it.

I declared 2 variables, say $foo and $bar. I have 2 for loops that goes and combine each of terms in file 1 to each of terms in file 2 and queries the database. Each time each term goes into the variables. The database is text-indexed. I am using DBI module. My query is something like this:

my $query_handle = $connect->prepare("SELECT value FROM value_table WHERE
MATCH(column_text_indexed) AGAINST ('+"$foo" +"$bar"' in boolean mode)") || die 
"Prepare failed:$DBI::errstr\n";

It gives the following error:

Scalar found where operator expected at program.pl line 32, near ""SELECT value FROM value_table
WHERE MATCH(column_text_indexed) AGAINST ('+"$foo"
        (Missing operator before $foo?)
String found where operator expected at program.pl line 32, near "$foo" +""
    (Missing operator before " +"?)
Scalar found where operator expected at program.pl line 32, near "" +"$bar"
    (Missing operator before $bar?)
String found where operator expected at program.pl line 32, near "$bar"' in boolean mode)""
    (Missing operator before "' in boolean mode)"?)
syntax error at program.pl line 32, near ""SELECT value FROM value_table WHERE
MATCH(column_text_indexed) against ('+"$foo"
Execution of program.pl aborted due to compilation errors.

Also, my other concern: is it right to use quotes around the terms when the terms are like “81-alpha-hydroxylase deficiency” or “26-deoxysteroid activity stable”? According to the http://dev.mysql.com/doc/refman/5.5/en/fulltext-boolean.html it says to use quotes if one is searching for exact terms and I want the exact terms to be searched. When I use () I get results but then I think it considers the whole word separated by spaces as different words and gives me result for any one of it.

Any help is greatly appreciated.

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:53:20+00:00Added an answer on May 27, 2026 at 11:53 am

    Say you want to create the string

    +"foo" +"bar"
    

    (Yes, I’m ignoring interpolation for now.)

    You can’t just place the whole thing in double quotes because the string literal will end at the first double quote encountered. You also need to escape the existing double quotes (and any other characters that are special in double-quoted strings).

    "+\"foo\" +\"bar\""
    

    Alternatively, you can use a different delimiter like

    qq!+"foo" +"bar"!
    

    or

    qq{+"foo" +"bar"}
    

    Now let’s interpolate the values we actually want.

    qq{+"$foo" +"$bar"}
    

    All together:

    my $sth = $dbh->prepare(qq{
       SELECT value
         FROM value_table
        WHERE MATCH (column_text_indexed) AGAINST (? IN BOOLEAN MODE)
    });
    
    $sth->execute(qq{+"$foo" +"$bar"});
    

    Note the use of a placeholder! Always use placeholders. (Search for that word in the DBI documentation if you don’t know this already.) If $foo or $bar contains a double-quote or other weird characters, your data won’t be accidentally interpreted as code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(I think this question has been asked before, but the answers have been contradictory
I don't think this question has been asked before. I'm a bit confused on
I think this is a moderately neophyte question. I've been using NHibernate/FluentNHibernate for about
I am using the SQL Server PHP Driver, I think this question can be
This question may have been asked already - but unfortunately, I could not find
I know this question has been asked here before, but I don't think those
Now similar question(s) has been asked at other places. However, I have tried the
I know this question has been asked many times and we have gotten this
Looking at the related questions, I don't think this specific question has been asked,
I honestly have no idea if this question has been asked before, or something

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.