LOL Roger, I didn't see that the first time through. This code is so bunched up, that on the quick glance, I kinda skipped over the comments. (See at the end of my first post? Rewrite your SQL statement without the ternary and I'll take a look a bit harder.) I guess I didn't look that hard to begin with. LOL
In all fairness weewizard, if you are using code someone else wrote, then I recommend you first consult with them. (especially if they resort to ternarys) If they can't or won't help you, I suggest you be open for some radical changes in the code you have.
One other things I noticed is this:
if ($search == "")
{$search = '%';}
(This looks as though the author assumes register globals is on. If your php.ini has register globals off, then this code won't work for you anyhow. You may want to change it to something like this:
$search = $_POST['search']; //Change to GET if using GET instead of POST.
if ($search == "")
{$search = '%';}