PHP/MySQL Boolean Search Script Updated

October 21, 2007

Topics: Web Development.

Just a quick announcement that I’ve updated my search script for Boolean matching in MySQL. The latest version is available for download on the PHP (Hypertext PreProcessing)/MYSQL Search Engine script page.

The changes to this version include:

  • Fixed: various minor bugs
  • Fixed: multipage results not available with quoted strings
  • Fixed: full-text query problem
  • Fixed: some compatibility issues with different PHP/MySQL configurations.
  • Added: sortable results
  • Added: configurable field label names
  • Added: sample results page
  • Added: test mode for troubleshooting.

It’s not a massive update; but the script should be easier to use and more reliable.

Have something to contribute?

« Read my Comment Policy

11 Comments on “PHP/MySQL Boolean Search Script Updated”

  1. @robson – Hi! I’ve been out of town for the last few days, but I’ll take a look when I get a chance.

    @olli – I appreciate your comments, but you’re addressing them to the wrong person. That’s the way the * operator was designed in MySQL: it operates as a terminal wildcard, not an initial wildcard. More about Boolean queries in MySQL.


  2. Hi,

    nice Script, but “*enwood” returns no results (Kenwood)… 🙁

  3. Sorry to bother you again, man, but I’m havin a little problem with the script and maybe you can help me.
    On saturday, I made my company’s most recent project public. Its a search engine where people can find the whole content of the local phone book online.
    The problem I’m having is that I’m not finding some things that I know that are in the DB. I dont know if it’s my mistake or it’s not a mistake at all.
    The only modifications I made to your original script were: I made it OO to suit the rest of the project, I made every query start with a + when no operator is used and I put an * in every query. Its all on
    I hope u can help me and sorry, again, to bother u.
    Thanks in advance

  4. Thanks, Robson. The only way I know to use wildcards at the beginning of your query string is by using regular expressions — and (although I’m not 100% sure,) I don’t think you can combine regular expressions with the fulltext search expressions.

    What you could do is add a regular expression mode option to the script such that a person can elect to do a search providing only the end of the word, and it would run the search using the separate select statement with a regular expression — but, sadly, the fulltext options simply don’t include a stemming selector. Maybe someday…

  5. Thank you very much for the script, Joe. I’ve been using it since version 1.5 and I’m always glad to find out the great enhancements you always make to it.
    I really need to use a wildcard both in the beginning and in the end of the query string. I’ve searched extensively to find out a way to accomplish it but I’m still clueless. Is there a way or a workaround I can implement in order to get to it?? Sorry to bother. And thank you very much again.

  6. Thanks, Alen! Look forward to hearing from you after you’ve finished things up.

  7. I just found your script googling out to find a nice php script to run on my website.
    after trying your demo i got a GREAT impression about it! Bravo!

    After putting it in production i will let you know!


  8. In fact, it does support the “*” wildcard operator. It’s only available as a final wildcard, but you can enter “cur*” to perform a search for terms beginning with “cur.” (Curtain, curtail, current, etc.)

    I think that this is documented in the script somewhere, although I’ll be honest that I don’t recall the details right now…

    I appreciate the comment, however, and I’ll make a point of adding that to the documentation as soon as possible!

  9. Thanks for this lovely site and this utility. I wonder, is there a reason why it searches for whole words only? We have a small database but there are some technical terms which are difficult to spell. Is it possible for users to add an * or something if they want a truncated value?

  10. Certainly worth noting. I can’t honestly say that PHP (Hypertext PreProcessing) 6 is at the front of my thoughts right now — given how long it takes for these things to move into production environments. However, since preg functions are available now, I might as well make the switch!

    Thanks –

  11. Nice job Joe. I do want to note one thing: The ereg()/eregi() functions will no longer be supported with PHP6 so you might want to replace that with preg_match() in the next build.