-6

我的程序有什么问题?我似乎无法使用“找不到单词”?:/

echo "<form action='#' method='post'>";
echo "Search word here: <input type='text' name='search'>";
echo "<input type='submit' name='searchword' value='Search'>";
echo "</form>";
if(isset($_POST['searchword'])){
    $word = $_POST['search'];
    $result = mysql_query("SELECT * FROM positivethesaurus where word like '%$word%'");
    while($row = mysql_fetch_array($result)){   
    echo $row['word']."<br>";
    }
    if($row = mysql_fetch_array(!$result)){
        echo "word not found";
    }
}
4

3 回答 3

3

我认为您将值分配给$word错误的字段名

$word = $_POST['search'];

它应该是

$word = $_POST['searchword'];

我只是在猜测,因为您正在检查它是否设置了此字段名称。

我希望它对你有帮助。

于 2013-02-27T12:48:50.343 回答
1

您的发布值是错误的。改成,

$word = $_POST['searchword'];

从,

$word = $_POST['search'];
于 2013-02-27T12:47:55.100 回答
0

word 可能是保留词,试试这个

"SELECT * FROM positivethesaurus where `word` like '%$word%'"
于 2013-02-27T12:47:38.470 回答