arden Posted May 7, 2010 Share Posted May 7, 2010 whats wrong with this code <?if ($searching =="yes") { echo "<h2>Results</h2><p>"; if ($find == "") { echo "<p>You forgot to enter a search term"; exit; } mysql_connect("localhost", "root", "pass") or die(mysql_error()); mysql_select_db("data_db") or die(mysql_error()); $find = strtoupper($find); $find = strip_tags($find); $find = trim ($find); $data = mysql_query("SELECT * FROM Persons WHERE upper($field) LIKE'%$find%'"); while($result = mysql_fetch_array( $data )) { echo $result['FirstName']; echo " "; echo $result['LastName']; echo "<br>"; echo $result['Age']; echo "<br>"; echo $result['Email']; echo "<br>"; } $anymatches=mysql_num_rows($data); if ($anymatches == 0) { echo "Sorry, no data found<br><br>"; } echo "<b>Searched For:</b> " .$find; } ?> <html><head><title>SEARCH</title></head><body><h2>Search</h2> <form name="search" method="post" action="<?$PHP_SELF?>"> Seach for: <input type="text" name="find" /> in <Select NAME="field"> <Option VALUE="FirstName">First Name</option> <Option VALUE="LastName">Last Name</option> <Option VALUE="Age">Age</option> </Select> <input type="hidden" name="searching" value="yes" /> <input type="submit" name="search" value="Search" /> </form></body></html> pls help.. Link to comment Share on other sites More sharing options...
Synook Posted May 7, 2010 Share Posted May 7, 2010 You forgot to begin an else block. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.