Only two selections allowed, then 'no results'

Jason's Avatar

Jason

04 Nov, 2011 12:23 PM

I have a weird problem that I can't seem to work out.

I have my script working fine, and I've even done some UTF8 de-/encoding to support foreign characters in searches.
However, when I've selected two 'tags' (results), I get the emptyText and no results show up although there are definitely more results in the database (btw, I tried removing the UTF8 part, same error as below). Here's the code:

PHP (handleTags.php):

include "db.php"; // database stuff (not secure, but just for now)
$input = utf8_decode($_GET["q"]);
$data = array();
$sql = mysql_query("SELECT * FROM tag WHERE tag LIKE '%$input%'");
while($row = mysql_fetch_assoc($sql)) {
    $json = array();
    $json['tag'] = utf8_encode($row['tag']);
    $json['id'] = $row['id'];
    $data[] = $json;
}
header("Content-type: application/json");
echo json_encode($data);

JAVASCRIPT:

$(document).ready(function(){
    $("input[type=text]#tagSuggest").autoSuggest("handleTags.php", {
        searchObjProps:"tag",
        selectedItemProp:"tag",
        startText: "Enter tags",
        emptyText: "No tags found"
    });
});

HTML:

I tried to load all tags on page load into a JSON obj and then using that for the AutoSuggest, but I couldn't get it working, and also, I would much rather like to find out what this problem is caused by. I run jQuery 1.4 and have also tried with 1.5, nothing works.

Please help me, much appreciated.

  1. 1 Posted by Jason on 04 Nov, 2011 12:24 PM

    Jason's Avatar

    The HTML didn't show, but it is:
    <? echo ''; ?>

  2. 2 Posted by Jason on 04 Nov, 2011 12:26 PM

    Jason's Avatar

    oh well, html not welcome.. it's a standard text field with id = tagSuggest

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac