0

これは私のデータベースの検索ボックスのコーディングですが、実行するとエラーが表示されます注意:未定義の変数:15行目の/opt/lampp/htdocs/1234.phpで検索し、検索ボックスに「オブジェクト」と表示されます。見つかりません!

要求されたURLはこのサーバーで見つかりませんでした。参照ページのリンクが間違っているか、古くなっているようです。そのページの作成者にエラーについて知らせてください。

これがサーバーエラーであると思われる場合は、ウェブマスターに連絡してください。

エラー404

localhost 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の知識を得るためにインターネットリファレンスを使用しています。このスクリプトを修正できますか

4

2 に答える 2

0

以下のように使用します。

extract($_POST);
 if ($searching =="yes") 
于 2013-03-27T10:16:52.590 に答える
0

$searching現時点では、スクリプトでは定義されていません。私はあなたが意味すると思います$_POST['searching']

if (isset($_POST['searching'])) { //old if }比較の周りに追加して、それ$_POST['searching']が設定されていることを確認し、次のように置き換え$searchingます$_POST['searching']

編集:に置き換え$PHP_SELF$_SERVER['PHP_SELF']ください、これはあなたを助けることができます。

于 2013-03-27T10:17:12.593 に答える