Почему мой мгновенный поиск не работает?

0

onlythebestoftheweb.x10.mx/test search/search.html Что не так с кодом? Попробуйте ввести что-нибудь там, не нажав кнопку ввода. Раньше это работало... Я не знаю, какие проблемы находятся в строках 3 и 31. Heres links.xml и livesearch.php

onlythebestoftheweb.x10.mx/test search/links.xml
 onlythebestoftheweb.x10.mx/test search/livesearch.php

Код Php

    <?php
$xmlDoc=new DOMDocument();
$xmlDoc->load("links.xml");

$x=$xmlDoc->getElementsByTagName('link');

//get the q parameter from URL
$q=$_GET["q"];

//lookup all links from the xml file if length of q>0
if (strlen($q)>0)
{
$hint="";
for($i=0; $i<($x->length); $i++)
  {
  $y=$x->item($i)->getElementsByTagName('title');
  $z=$x->item($i)->getElementsByTagName('url');
  if ($y->item(0)->nodeType==1)
    {
    //find a link matching the search text
    if (stristr($y->item(0)->childNodes->item(0)->nodeValue,$q))
      {
      if ($hint=="")
        {
        $hint="<a href='" . 
        $z->item(0)->childNodes->item(0)->nodeValue . 
        "' target='_blank'>" . 
        $y->item(0)->childNodes->item(0)->nodeValue . "</a>";
        }
      else
        {
        $hint=$hint . "<br /><a href='" . 
        $z->item(0)->childNodes->item(0)->nodeValue . 
        "' target='_blank'>" . 
        $y->item(0)->childNodes->item(0)->nodeValue . "</a>";
        }
      }
    }
  }
}

// Set output to "no suggestion" if no hint were found
// or to the correct values
if ($hint=="")
  {
  $response="no suggestion";
  }
else
  {
  $response=$hint;
  }

//output the response
echo $response;
?>
  • 0
    Вы должны предоставить исходный текст PHP.
  • 0
    Решено извините. Лол. Забыли добавить открывающий тег <link>
Показать ещё 1 комментарий
Теги:

1 ответ

1
Лучший ответ

Вам не хватает открывающего <link> между строками 27 и 28 links.xml.

Chrome предоставляет мне полезную ошибку, если я перейду к: http://onlythebestoftheweb.x10.mx/test%20search/links.xml

  • 0
    Извините, я так глуп: P, я просто забыл.
  • 1
    Заплати мужчине! :)
Показать ещё 5 комментариев

Ещё вопросы

Сообщество Overcoder
Наверх
Меню