Hi, I’m coding a search bar for a project, but it doesn’t really work. If I have a product in my database called product e, and write e in the database, the product will, of course, show up. But if I then write e+htyjfthtyhrf, it will still display that product, but it should display no matches! Do anyone know how I can fix this?
Ah, I was looking at the search on your home page, thank you for submitting the right URL.
I checked a complicated query like the one in your original post. However, I saw this error in the response:
<br />
<b>Warning</b>: array_unique() expects parameter 1 to be array, string given in <b>/home/vol11_3/epizy.com/epiz_21490173/htdocs/test_update/fetch.php</b> on line <b>45</b><br />
Maybe it’s unrelated, but it wouldn’t hurt to address it.
I would recommend to start with classic search button and form
<form role="search" method="get"><input type="text" name="q" placeholder="Type search text and hit enter"></form>
and then put on that button and label some listeners (if clicked, mousedown, enter key pressed, etc.)
then grab the user input from search label
parse this input (toLowerCase, no white space, no hack stuff, chars limit, minimum char lenght for search, etc.)
I checked bootstrap3-typeahead.min.js
and find .bind which is obsolete and is not compatible with jquery v3
The simplest solution is to edit the script and change it with the appropriate one .on
and serve on your server
But I’m Kinda new to this, and I have No idea about how to fix the array_unique thing. Do you know how to do it?
Thanks
You need to rewrite your code so the array_unique line is only hit if there actually are any results. Or you need to make sure that $data always contains an array. There are many, many different ways to work around this.