Note that there are some explanatory texts on larger screens.

plurals
  1. POgot error when using search from
    text
    copied!<pre><code>&lt;h2&gt;Search&lt;/h2&gt; &lt;form name="search" method="post" action="&lt;?php $_SERVER['PHP_SELF']; ?&gt;"&gt; Seach for: &lt;input type="text" name="find" /&gt; in &lt;Select NAME="field"&gt; &lt;Option VALUE="fname"&gt;First Name&lt;/option&gt; &lt;Option VALUE="lname"&gt;Last Name&lt;/option&gt; &lt;Option VALUE="info"&gt;Profile&lt;/option&gt; &lt;/Select&gt; &lt;input type="hidden" name="searching" value="yes" /&gt; &lt;input type="submit" name="search" value="Search" /&gt; &lt;/form&gt; &lt;?php //This is only displayed if they have submitted the form if ($_REQUEST[searching] =="yes") { echo "&lt;h2&gt;Results&lt;/h2&gt;&lt;p&gt;"; //If they did not enter a search term we give them an error if ($_REQUEST[find] == "") { echo "&lt;p&gt;You forgot to enter a search term"; exit; } // Otherwise we connect to our Database mysql_connect("localhost", "admin", "password") or die(mysql_error()); mysql_select_db("oop") or die(mysql_error()); // We preform a bit of filtering $find = strtoupper($_REQUEST[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($_REQUEST[field]) LIKE'%$find%'"); //And we display the results while($result = mysql_fetch_array( $data )) { echo $result['fname']; echo " "; echo $result['lname']; echo "&lt;br&gt;"; echo $result['info']; echo "&lt;br&gt;"; echo "&lt;br&gt;"; } //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&lt;br&gt;&lt;br&gt;"; } //And we remind them what they searched for echo "&lt;b&gt;Searched For:&lt;/b&gt; " .$find; } ?&gt; </code></pre> <p>Question:</p> <p>The front end shows:</p> <blockquote> <p>Notice: Use of undefined constant searching - assumed 'searching' in D:\wamp\www\oop\test2.php on line 15</p> </blockquote> <p>I know something wrong with posting the form values, such as 'searching'...but i do now know how to correct/change. so anyone can help me to correct it?</p> <p>Thanks.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload