PHP: Create ajax auto-suggest -


i create simple ajax auto-suggest can retrieve data database.

you can see here :

index.php

<html> <head> <script type="text/javascript"> function suggest() {     var txtsearch = document.getelementbyid('txtsearch').value;      if (window.xmlhttprequest) {         xmlhttp = new xmlhttprequest();     } else {         xmlhttp = new activexobject('microsoftxmlhttp');     }     xmlhttp.onreadystatechange = function() {         if (xmlhttp.readystate == 4 && xmlhttp.status == 200) {             document.getelementbyid('mydiv').innerhtml = xmlhttp.responsetext;         }     }     var target = 'include.inc.php?txtsearch=' + txtsearch;     xmlhttp.open('get', target, true);     xmlhttp.send(); } </script> </head> <body> <input type="text" id="txtsearch" onkeyup="suggest();"/> <div id="mydiv"></div> </body> </html> 

incldue.inc.php

<?php  require_once 'connect.inc.php';  if (isset($_get['txtsearch'])) {     $txtsearch = $_get['txtsearch'];     getsuggest($txtsearch); }  function getsuggest($text) {      $sqlcommand = "select `surname` `person` `surname` '%$text%'";      $query = mysql_query($sqlcommand);      $result_count = mysql_num_rows($query);      while ($row = mysql_fetch_assoc($query)) {         echo $row['surname'].'<br />';     }  ?> 

the problem :

get following error on line 22, have no idea why :

parse error: syntax error, unexpected end of file in c:\wamp\www\php_ajax_autosuggest\include.inc.php on line 22 

p.s :

and didn't mentioned connect.inc.php content, because works fine.

any great appreciated.

jothikannan mentioned quotation marks issue, makes sense me. think forgot end getsuggest() function, though. add } before ?> in file.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

.htaccess - Matching full URL in RewriteCond -