Форум АНТИЧАТ

Форум АНТИЧАТ (https://forum.antichat.xyz/index.php)
-   PHP, PERL, MySQL, JavaScript (https://forum.antichat.xyz/forumdisplay.php?f=37)
-   -   Не работает поиск по сайту (https://forum.antichat.xyz/showthread.php?t=138057)

selevit 29.08.2009 08:18

Не работает поиск по сайту
 
Всем доброго времени суток! я написал небольшой скрипт поиска для своего сайта на php - Вот сама страница со скриптом:

Код HTML:

<? include ("blocks/bd.php");
if (isset($_POST['submit_s']))
{
$submit_s = $_POST['submit_s'];
}

if (isset($_POST['search']))
{
$search = $_POST['search'];
}

if (isset($submit_s))
{

if (empty($search) or strlen($search) < 4)
{
exit ("<p>Поисковый запрос не введен, либо он менее 4-х символов.</p>");
}

$search = trim($search);
$search = stripslashes($search);
$search = htmlspecialchars($search);

}

else
{
exit("<p>Вы обратились к файлу без необходимых параметров.</p>");
}




?>





<link href="style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="900" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="main_border">

<?php include ("blocks/header.php");?>

  <tr>
    <td valign="top"><table width="100%" border="0" cellpadding="0" cellspacing="0" class="top" id="s">
      <tr>
        <?php include ("blocks/left_td.php");?>
        <td width="77%" align="left" valign="top">
       
       
        <p class="nav_title">Поиск</p>
       
     
                <?php
               
                $result = mysql_query("SELECT id,title,description,date,author,view,download FROM data WHERE MATCH(text) AGAINST('$search')",$db);
               
                if (!$result)
        {
        echo "<p>Запрос на выборку данных из базы не прошел. Напишите об этом администратору admin@ruseller.com. <br> <strong>Код ошибки:</strong></p>";
        exit(mysql_error());
        }

      if (mysql_num_rows($result) >
0)

        {
        $myrow = mysql_fetch_array($result);

                do
               
               
                {
               
               
                printf ("    <table align='center' class='post'>
            <tr>
            <td>
                        <p class = 'nav_link'><a href='view_post.php?id=%s'>%s</a>
                        <p class = 'post_adds'>Дата Добавления: %s</p>
                        <p class = 'post_adds'>Добавил: %s</p>
                        </td>
            </tr>
                        <tr>
                        <p><td>%s
                        <p class = 'post_view'>Просмотров: %s</p>
                        <p class = 'post_view'>Загрузок: %s</p>
                        </tr>
            </table>", $myrow['id'], $myrow['title'], $myrow['date'], $myrow['author'], $myrow['description'], $myrow['view'], $myrow['download']);
               
               
               
                }
                while ($myrow = mysql_fetch_array($result));



}

else
{
echo "<p>Информация по Вашему запросу на блоге не найдена.</p>";
exit();
}

?>
 
       
        </td>
      </tr>
    </table></td>
  </tr>
<?php include ("blocks/footer.php");?>
</table>




при правильном поисковом запросе он ничего не находит.

L I G A 29.08.2009 11:52

попробуй заменить :
$result = mysql_query("SELECT id,title,description,date,author,view,download FROM data WHERE MATCH(text) AGAINST('$search')",$db);

на:

$result = mysql_query("SELECT id,title,description,date,author,view,download FROM data WHERE MATCH(text) AGAINST('".$search."')",$db);

mailbrush 29.08.2009 12:31

Цитата:

Сообщение от L I G A
попробуй заменить :
$result = mysql_query("SELECT id,title,description,date,author,view,download FROM data WHERE MATCH(text) AGAINST('$search')",$db);

на:

$result = mysql_query("SELECT id,title,description,date,author,view,download FROM data WHERE MATCH(text) AGAINST('".$search."')",$db);

Это ничего не изменит, переменные в двойных кавычках обрабатываются как переменные :)

.::BARS::. 29.08.2009 18:00

Цитата:

$result = mysql_query("SELECT id,title,description,date,author,view,download FROM data WHERE MATCH(text) AGAINST('$search')",$db);
а нельзя просто
Цитата:

$result = mysql_query("SELECT id,title,description,date,author,view,download FROM data WHERE text='$search'",$db);
?


Время: 23:42