Update to Search script in MySQL/PHP

I know it’s only been a month, so it’s obviously far too soon for me to be publishing any kind of a script update. However, these were things which just needed to be done.

First, I’ve greatly improved the internationalism of the script: it now operates searches on UTF-8 encoded data, so it should be great for working with any language which requires characters in that character set. Testing this kind of behavior is difficult, so if you should encounter any problems please do let me know!

Second, I improved the pagination of results. Previously, if there were 150 pages of results, you’d have to see links to every single page of the results. Granted, this can be advantageous, but it’s not really practical. In this updated version, when there are more than 10 pages of results you’ll only have links to the first page, the last page, and two pages before and after the current page. This boundary is configurable — you can offer 50 pages before and after the current, if you wish, but the default is 2.

Last, I changed the way the search query was checked before being sent to MySQL. The original version of this script used my own custom-authored regular expression to secure the request. This was probably very secure, since it functioned by only allowing certain characters rather than checking restricted characters — but it did make things such as multibyte queries pretty much impossible. So it was time to change over to a more standard method. So be it! I got what I needed out of the regular expression; it didn’t need to stay in the script.

MySQL/PHP Boolean Search Updated

Following the publication of a brief article on Search results design by Adaptive Path, I decided that revising my database search script was a valuable goal. Specifically, meeting the checklist in that result was probably not a bad idea!

It’s not that the previous version was terrible, but I knew perfectly well that it could be much better.

The additions to the script are pretty straightforward:

Additions:

  • Added: Made row highlighting available in both tabular and list-based search results.
  • Added: Search terms are now highlighted in search results.
  • Added: The default sort is now to order results by query relevance.
  • Added: Paginated navigation of search results is now available.
  • Added: Translation base file [English], so translating the script is easier.
  • Added: Basic Spellchecking [English]
  • Added: Default stylesheet

Changes:

  • Changed: Text excerpts are now truncated at word boundaries, rather than in the middle of words.
  • Changed: separated results template information into external include files for easier upgrading or modification.
  • Changed: Included the search form as part of the script so that search terms could be automatically returned to the search input.

The spell checking is the most exciting addition in my view. It’s hardly complete, but it’s based on a list of 4,068 common misspellings available from Wikipedia. This addition has significantly bulked up the total download size, since I’m including the spell-checking database as part of the download, but I think it adds a lot of value to the script.

I’ve also added a translation base file to the package, to make it a bit easier for users of the script to port it to their own languages. Unfortunately, I haven’t yet had time to seriously work on the internationalization of the search script itself, so (to be entirely frank) this is an area which the script isn’t really well suited at this time.

Internationalization is next on the list, however. It’s a high priority at this point, since internationalization ranks as one of the most reported problems with the script.

With spell-checking in mind, I think it’s appropriate to provide a healthy reminder of the limitations of spellcheck:

Candidate for a Pullet Surprise

by Mark Eckman and Jerrold H. Zar

I have a spelling checker,
It came with my PC.
It plane lee marks four my revue
Miss steaks aye can knot sea.

Eye ran this poem threw it,
Your sure reel glad two no.
Its vary polished in it’s weigh.
My checker tolled me sew.

A checker is a bless sing,
It freeze yew lodes of thyme.
It helps me right awl stiles two reed,
And aides me when eye rime.

Each frays come posed up on my screen
Eye trussed too bee a joule.
The checker pours o’er every word
To cheque sum spelling rule.

Bee fore a veiling checker’s
Hour spelling mite decline,
And if we’re lacks oar have a laps,
We wood bee maid too wine.

Butt now bee cause my spelling
Is checked with such grate flare,
Their are know fault’s with in my cite,
Of nun eye am a wear.

Now spelling does knot phase me,
It does knot bring a tier.
My pay purrs awl due glad den
With wrapped word’s fare as hear.

To rite with care is quite a feet
Of witch won should bee proud,
And wee mussed dew the best wee can,
Sew flaw’s are knot aloud.

Sow ewe can sea why aye dew prays
Such soft wear four pea seas,
And why eye brake in two averse
Buy righting want too pleas.

Google Site Links for “Joe Dolson”

This is just cool:

Joe Dolson Sitelinks

Sitelinks” are additional links Google generates from the contents of a site in order to help users navigate your site — they provide these links in their search results for selected terms. Most sites don’t have site links, so I’m finding it pretty cool to notice them for myself!

If you can’t see the image, the current Sitelinks for this site are:

On the whole, I’m pretty pleased with the selection chosen here. They’ve pretty well pinned down the key areas of the site: web design, web accessibility, search marketing, and my writing on these topics. Everything is reasonably represented. Perhaps, in my forthcoming site redesign (don’t keep a look out; it’s not going to be that soon,) I’ll make a point to better promote these specific areas of the site.

PHP/MySQL Boolean Search Script Updated

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/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.

Return to Top