這是我在我的數據庫中搜索框的編碼,但是當我運行它時它顯示錯誤注意:未定義變量:在第15行的/opt/lampp/htdocs/1234.php中搜索 然後ii在我的搜索框中輸入任何內容 它表示 找不到對象!php中的搜索框創建
在此服務器上找不到請求的URL。推薦頁面上的鏈接似乎是錯誤或過時的。請通知該頁面的作者關於錯誤。
如果您認爲這是服務器錯誤,請與網站管理員聯繫。
錯誤404
本地主機 的Apache/2.4.3(UNIX)的OpenSSL/1.0.1c PHP/5.4.7
<html>
<h2>Search</h2>
<form name="search" method="post" action="<?=$PHP_SELF?>">
Seach for: <input type="text" name="find" /> in
<Select NAME="field">
<Option VALUE="fname">diseasename</option>
<Option VALUE="lname">genename</option>
</Select>
<input type="hidden" name="searching" value="yes" />
<input type="submit" name="search" value="Search" />
</form>
</html>
<?php
//This is only displayed if they have submitted the form
if ($searching =="yes")
{
echo "<h2>Results</h2><p>";
//If they did not enter a search term we give them an error
if ($find == "")
{
echo "<p>You forgot to enter a search term";
exit;
}
// Otherwise we connect to our Database
mysql_connect("localhost", "root", "****") or die(mysql_error());
mysql_select_db("missensencemuttation") or die(mysql_error());
// We preform a bit of filtering
$find = strtoupper($find);
$find = strip_tags($find);
$find = trim ($find);
//Now we search for our search term, in the field the user specified
$data = mysql_query("SELECT * FROM users WHERE upper($field) LIKE'%$find%'");
//And we display the results
while($result = mysql_fetch_array($data))
{
echo $result['fname'];
echo " ";
echo $result['lname'];
echo "<br>";
echo $result['info'];
echo "<br>";
echo "<br>";
}
//This counts the number or results - and if there wasn't any it gives them a little message explaining that
$anymatches=mysql_num_rows($data);
if ($anymatches == 0)
{
echo "Sorry, but we can not find an entry to match your query<br><br>";
}
//And we remind them what they searched for
echo "<b>Searched For:</b> " .$find;
}
?>
我不知道我做錯了什麼在我的腳本。而我在PHP初學者,我使用爲獲得在php.can一個知識解決此腳本
謝謝suresh,但是當我點擊搜索按鈕這是什麼它顯示對象沒有找到! 在此服務器上找不到請求的URL。推薦頁面上的鏈接似乎是錯誤或過時的。請通知該頁面的作者關於錯誤。 如果您認爲這是服務器錯誤,請與網站管理員聯繫。 錯誤404 本地主機 的Apache/2.4.3(UNIX)的OpenSSL/1.0.1c PHP/5.4.7 – 2013-03-27 10:22:42