php和mysql搜索代码不工作(请查看代码并调试)

php和mysql搜索代码不工作(请查看代码并调试),php,mysql,full-text-search,Php,Mysql,Full Text Search,我创建search.php并创建数据库war和表产品 我的代码不起作用: <!DOCTYPE html> <html> <head> <title>Search</title> </head> <body> <form method="get" action=""> <table> <tr>

我创建search.php并创建数据库war和表产品

我的代码不起作用:

<!DOCTYPE html>
<html>
<head>
    <title>Search</title>
</head>
<body>
    <form method="get" action="">
        <table>
            <tr>
                <td>متن برای جستجو</td>
                <td><input type="text" name="text"></td>
            </tr>
            <tr>
                <td><input type="submit" value="Search"></td>
                <td>
                <?php
                    if(isset($_GET['text']) && !empty($_GET['text'])){
                        $body=$_GET['text'];
                        $con=mysql_connect("localhost","root","");
                        if(!$con){die("mysql Error");}
                        if (!mysql_select_db("war",$con)){die("mysql select error");}
                        $res=mysql_query("SELECT * FROM product WHERE LIKE pname='%$body%'");
                        $count=mysql_num_rows($res);
                        if ($count <= 0){
                            die("Your product Not found");

                        }else{
                            while ($row=mysql_fetch_array($res)){
                                echo $row['pname'];
                            }
                        }
                    }
                ?>

                </td>
            </tr>
        </table>
    </form>
</body>
</html>
请帮助并调试。

您的MySQL SELECT语句错误。应该是:

$res=mysql_query("SELECT * FROM product WHERE pname LIKE '%$body%'"); // note the absence of =
当然,如果这是你的意思,那么它就不起作用了


PS:不要使用mysql_*函数

如果没有完整的代码,我们如何帮助和调试?“不工作”不是问题描述StackOverflow是一个问答网站,不是一个发布plz修复我的codez请求伪装成问题的网站。请它们不再得到维护,而是在使用。学习替代,并考虑使用PDO。