Hi frnds....
i am trying to do search like google....

my files r here......but it displays nothing....i mean no output and no error...plz check the code what the error?

eg: in a text box type "a"
then "a" related words r displayed...


google.phpp

<?php
$file=fopen("http://www.google.com/complete/search?h1=en&js=true&qu=" . $_GET["qu"],"r");
while(!feof($file)){
$d=fgets($file);
echo $d;
echo "no";
}

fclose($file);

?>

google.html

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>google search</title>
<script language="javascript">
function getData(dataSource)
{
var XMLHttpRequestObject = false;
if(window.XMLHttpRequest){
XMLHttpRequestObject=new XMLHttpRequest();
}else if(window.ActiveXObject){
XMLHttpRequestObject=new ActiveXObject("Microsoft.XMLHTTP");
}
if(XMLHttpRequestObject){
XMLHttpRequestObject.open("GET",dataSource);
XMLHttpRequestObject.onreadystatechange=function(){
if(XMLHttpRequestObject.readyState ==4 && XMLHttpRequestObject.status==200){
eval(XMLHttpRequestObject.responseText);}
}
XMLHttpRequestObject.send(null);
}
}
function connectGoogleSuggest(keyEvent){
var input=document.getElementById("textField");
if(input.value){
getData("google.php?qu=" +input.value);
}else{
var targetDiv=document.getElementById("targetDiv");
targetDiv.innerHTML= "<div></div>";
}

}
function sendRPCDone(unusedVariable,searchTerm,arrayTerm,arrayResults,unusedArray){
var data="<table>";
var loopIndex;

if(arrayResults.length !=0){
for(var loopIndex=0; loopIndex < arrayResults.length; loopIndex++){
data +="<tr><td>" + "<a href='http://www.google.com/search?q=" + arrayTerm[loopIndex] +"'>" +arrayTerm[loopIndex] +'</a></td><td>' + arrayResults[loopIndex] + "</td></tr>";
}
}
data +="</table>" ;
var targetDiv=document.getElementById("targetDiv");
targetDiv.innerHTML=data;
}
</script>
</head>

<body>
<input id="textField" type="text" name="textField" onkeyup="connectGoogleSuggest(event)" />
<div id="tagetDiv" ><div></div></div>


</body>
</html>

Hi ...

here is a mistake in my above code..(spelling)

<div id="targetDiv" ><div></div></div>....


now i got some error message at the bottom(footer) of my page, when press a key...

error:'window.google.ac' is null or not an object.
char:1.
line:19.

plz check the code...

yeah i am looking for a solution to the same problem too... but no luck yet...
did u find it out... if yes, could you plz post it here so others can benefit from it too...

This article has been dead for over six months. Start a new discussion instead.