Hello, everyone...
So, I've got this problem I can't decide, maybe there is someone smarter or more experienced who can help me .
On my web-site I'm using auto-suggest live-search field which works like a charm in every browser besides Opera (( In Opera when I type something the search gives me multiple results. for example if I search the word "home", in results it shows me "home" 4 times. (((
I'm using linux server and here are the scripts which I'm using for live search:
This is ajax code in js file:
Code:
function Initialize()
{
try
{
http=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
http=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(oc)
{
http=null;
}
}
if(!http&&typeof XMLHttpRequest!="undefined")
{
http=new XMLHttpRequest();
}
}
function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer")
{
request_type = new ActiveXObject("Microsoft.XMLHTTP");
}else{
request_type = new XMLHttpRequest();
}
return request_type;
}
var XMLHttp = createObject();
function autosuggest() {
Initialize();
var q = null;
var q = encodeURIComponent(document.getElementById("search-q").value);
nocache = Math.random();
XMLHttp.open("get","english_search.php?q="+q+"&&nocache="+nocache);
XMLHttp.onreadystatechange = autosuggestReply;
XMLHttp.send(null);
}
function hileload()
{
document.getElementById("results").style.display = "none";
}
function autosuggestReply() {
Initialize();
if(XMLHttp.readyState == 2)
{
}
if (XMLHttp.readyState == 4)
{
hileload();
if (XMLHttp.status == 200)
{
var response = XMLHttp.responseText;
e = document.getElementById("results");
if(response!=="");{
e.innerHTML=response;
e.style.display="block";
}
}
}
}
and here is .php file code for mysql database:
Code:
<?php
include('config.php');
?>
<?php
$SQL_FROM = 'eng';
$SQL_WHERE = 'english';
$q = rawurldecode($_GET['q']);
$searchq = strip_tags($_GET['q']);
$getRecord_sql = 'select * from '.$SQL_FROM.' where '.$SQL_WHERE.' like "'.$searchq.'%" LIMIT 7';
$characterSet = mysql_query;
if(!$characterSet){
die ('Can\'t set character set : ' . mysql_error());
}
$mysql_query = mysql_query("SET NAMES 'utf8'") or die ("Error".mysql_error());
$mysql_query = mysql_query("SET CHARACTER SET 'utf8'")or die ("Error".mysql_error());
$getRecord=mysql_query($getRecord_sql);
if(strlen($searchq)>0){
echo '<ul>';
while ($row = mysql_fetch_array($getRecord)) {?>
<li>
<font style="color:#0000FF; font-weight:bold; font-size:17px;"><?php echo $row['test1']; ?></font>
<font style="color:#00CC33; font-weight:bold;"><i><?php echo $row['test2']; ?></i></font>
</li>
<?php }
echo '</ul>';
?>
<?php } ?>
So, please help me someone and let me know if you need some more information on it. Oh, by the way, just for record: on localhost the search doesn't have any problem but after I uploaded it on my linux server I had to face this problem ((( Maybe just because the localhost works very fast... I don't know (( I have spent 2 weeks on this issue and can't fix it. So, sos
Bookmarks