【发布时间】:2013-02-13 06:47:05
【问题描述】:
我的程序有什么问题吗?我似乎无法使用“找不到单词”? :/
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";
}
}
【问题讨论】:
-
Please, don't use
mysql_*functions in new code。它们不再维护and are officially deprecated。看到red box?改为了解prepared statements,并使用PDO 或MySQLi - this article 将帮助您决定哪个。如果你选择 PDO,here is a good tutorial. -
仅供参考,你也对SQL injections敞开心扉
-
@F4r-20 感谢您的编辑(:我是新手
-
熟能生巧;)
-
@F4r-20 哈哈是的,我现在得到了答案
标签: php validation